diff --git a/s3fs.info.yml b/s3fs.info.yml index 0ae0124..9b77b2e 100644 --- a/s3fs.info.yml +++ b/s3fs.info.yml @@ -1,5 +1,5 @@ name: S3 File System -core: 8.x +core_version_requirement: ^8.8 || ^9 description: Adds an Amazon Simple Storage Service-based remote file system to Drupal. type: module configure: s3fs.admin_settings diff --git a/s3fs.services.yml b/s3fs.services.yml index 9b1ded6..f6d9c2b 100644 --- a/s3fs.services.yml +++ b/s3fs.services.yml @@ -1,7 +1,7 @@ services: s3fs: class: Drupal\s3fs\S3fsService - arguments: ['@database', '@config.factory'] + arguments: ['@database', '@config.factory', '@datetime.time'] stream_wrapper.s3fs: class: Drupal\s3fs\StreamWrapper\S3fsStream tags: diff --git a/src/S3fsService.php b/src/S3fsService.php index 7035f97..8e7f4fc 100644 --- a/src/S3fsService.php +++ b/src/S3fsService.php @@ -5,6 +5,7 @@ namespace Drupal\s3fs; use Aws\Credentials\CredentialProvider; use Aws\S3\Exception\S3Exception; use Aws\S3\S3Client; +use Drupal\Component\Datetime\TimeInterface; use Drupal\Core\Cache\Cache; use Drupal\Core\Config\ConfigFactory; use Drupal\Core\Database\Connection; @@ -36,6 +37,13 @@ class S3fsService implements S3fsServiceInterface { */ protected $configFactory; + /** + * An object for obtaining the system time. + * + * @vara \Drupal\Component\DateTime\TimeInterface + */ + protected $time; + /** * Constructs an S3fsService object. * @@ -43,10 +51,13 @@ class S3fsService implements S3fsServiceInterface { * The new database connection object. * @param \Drupal\Core\Config\ConfigFactory $config_factory * The config factory object. + * @param \Drupal\Component\DateTime\TimeInterface $time + * An object to obtain the system time. */ - public function __construct(Connection $connection, ConfigFactory $config_factory) { + public function __construct(Connection $connection, ConfigFactory $config_factory, TimeInterface $time) { $this->connection = $connection; $this->configFactory = $config_factory; + $this->time = $time; } /** @@ -371,7 +382,7 @@ class S3fsService implements S3fsServiceInterface { $metadata = [ 'uri' => $uri, 'filesize' => 0, - 'timestamp' => \Drupal::time()->getRequestTime(), + 'timestamp' => $this->time->getRequestTime(), 'dir' => 0, 'version' => '', ];