diff --git a/automatic_updates.services.yml b/automatic_updates.services.yml index 808ae6e7afc45426707695c27524d97b958027b2..4d07d4d0cce8852be94fe9a5065a94ff3d7b1ef7 100644 --- a/automatic_updates.services.yml +++ b/automatic_updates.services.yml @@ -9,57 +9,22 @@ services: automatic_updates.status_checker: class: Drupal\automatic_updates\Validation\StatusChecker arguments: - - '@keyvalue.expirable' - - '@datetime.time' - - '@event_dispatcher' - - '@automatic_updates.updater' - - '@automatic_updates.cron_updater' - - 24 + # @todo Remove this when https://drupal.org/i/3325557 lands. + $key_value_expirable_factory: '@keyvalue.expirable' + $resultsTimeToLive: 24 tags: - { name: event_subscriber } Drupal\automatic_updates\Validation\StatusChecker: '@automatic_updates.status_checker' automatic_updates.status_check_mailer: class: Drupal\automatic_updates\StatusCheckMailer - arguments: - - '@config.factory' - - '@plugin.manager.mail' - - '@language_manager' + Drupal\automatic_updates\StatusCheckMailer: '@automatic_updates.status_check_mailer' automatic_updates.updater: class: Drupal\automatic_updates\Updater - arguments: - - '@package_manager.composer_inspector' - - '@package_manager.path_locator' - - '@package_manager.beginner' - - '@package_manager.stager' - - '@package_manager.committer' - - '@file_system' - - '@event_dispatcher' - - '@tempstore.shared' - - '@datetime.time' - - '@PhpTuf\ComposerStager\Infrastructure\Factory\Path\PathFactoryInterface' - - '@package_manager.failure_marker' calls: - ['setLogger', ['@logger.channel.automatic_updates']] Drupal\automatic_updates\Updater: '@automatic_updates.updater' automatic_updates.cron_updater: class: Drupal\automatic_updates\CronUpdater - arguments: - - '@automatic_updates.release_chooser' - - '@plugin.manager.mail' - - '@automatic_updates.status_check_mailer' - - '@state' - - '@config.factory' - - '@package_manager.composer_inspector' - - '@package_manager.path_locator' - - '@package_manager.beginner' - - '@package_manager.stager' - - '@package_manager.committer' - - '@file_system' - - '@event_dispatcher' - - '@tempstore.shared' - - '@datetime.time' - - '@PhpTuf\ComposerStager\Infrastructure\Factory\Path\PathFactoryInterface' - - '@package_manager.failure_marker' calls: - ['setLogger', ['@logger.channel.automatic_updates']] Drupal\automatic_updates\CronUpdater: '@automatic_updates.cron_updater' @@ -69,9 +34,6 @@ services: - { name: event_subscriber } automatic_updates.staged_projects_validator: class: Drupal\automatic_updates\Validator\StagedProjectsValidator - arguments: - - '@package_manager.path_locator' - - '@package_manager.composer_inspector' tags: - { name: event_subscriber } Drupal\automatic_updates\Validator\StagedProjectsValidator: '@automatic_updates.staged_projects_validator' @@ -83,29 +45,20 @@ services: automatic_updates.cron_frequency_validator: class: Drupal\automatic_updates\Validator\CronFrequencyValidator arguments: - - '@config.factory' - - '@module_handler' - - '@state' - - '@datetime.time' - - '@automatic_updates.cron_updater' - - '@lock' + $lock: '@lock' tags: - { name: event_subscriber } automatic_updates.validator.staged_database_updates: class: Drupal\automatic_updates\Validator\StagedDatabaseUpdateValidator - arguments: - - '@package_manager.validator.staged_database_updates' tags: - { name: event_subscriber } automatic_updates.validator.version_policy: class: Drupal\automatic_updates\Validator\VersionPolicyValidator - autowire: true tags: - { name: event_subscriber } + Drupal\automatic_updates\Validator\VersionPolicyValidator: '@automatic_updates.validator.version_policy' automatic_updates.config_subscriber: class: Drupal\automatic_updates\EventSubscriber\ConfigSubscriber - arguments: - - '@automatic_updates.status_checker' tags: - { name: event_subscriber } automatic_updates.validator.scaffold_file_permissions: @@ -115,10 +68,6 @@ services: Drupal\automatic_updates\Validator\ScaffoldFilePermissionsValidator: '@automatic_updates.validator.scaffold_file_permissions' automatic_updates.validator.cron_server: class: Drupal\automatic_updates\Validator\CronServerValidator - arguments: - - '@request_stack' - - '@config.factory' - - '@module_handler' tags: - { name: event_subscriber } logger.channel.automatic_updates: diff --git a/automatic_updates_extensions/automatic_updates_extensions.services.yml b/automatic_updates_extensions/automatic_updates_extensions.services.yml index 7c40972b389edbc61da18b55a87995917ae82ea3..45cfaa4c16fe869578d4ad6f03d1f4b081c3a8e2 100644 --- a/automatic_updates_extensions/automatic_updates_extensions.services.yml +++ b/automatic_updates_extensions/automatic_updates_extensions.services.yml @@ -4,18 +4,6 @@ services: automatic_updates_extensions.updater: class: Drupal\automatic_updates_extensions\ExtensionUpdater - arguments: - - '@package_manager.composer_inspector' - - '@package_manager.path_locator' - - '@package_manager.beginner' - - '@package_manager.stager' - - '@package_manager.committer' - - '@file_system' - - '@event_dispatcher' - - '@tempstore.shared' - - '@datetime.time' - - '@PhpTuf\ComposerStager\Infrastructure\Factory\Path\PathFactoryInterface' - - '@package_manager.failure_marker' Drupal\automatic_updates_extensions\ExtensionUpdater: '@automatic_updates_extensions.updater' automatic_updates_extensions.validator.target_release: class: Drupal\automatic_updates_extensions\Validator\UpdateReleaseValidator diff --git a/automatic_updates_extensions/src/ExtensionUpdater.php b/automatic_updates_extensions/src/ExtensionUpdater.php index fc3813f67fb2898f7c0a78c344173d6198be7c8c..aebb4718f668cd578524d5f6828a4598249a83af 100644 --- a/automatic_updates_extensions/src/ExtensionUpdater.php +++ b/automatic_updates_extensions/src/ExtensionUpdater.php @@ -4,10 +4,20 @@ declare(strict_types = 1); namespace Drupal\automatic_updates_extensions; +use Drupal\Component\Datetime\TimeInterface; +use Drupal\Core\File\FileSystemInterface; use Drupal\Core\StringTranslation\TranslatableMarkup; +use Drupal\Core\TempStore\SharedTempStoreFactory; use Drupal\package_manager\ComposerInspector; +use Drupal\package_manager\FailureMarker; use Drupal\package_manager\LegacyVersionUtility; +use Drupal\package_manager\PathLocator; use Drupal\package_manager\Stage; +use PhpTuf\ComposerStager\Domain\Core\Beginner\BeginnerInterface; +use PhpTuf\ComposerStager\Domain\Core\Committer\CommitterInterface; +use PhpTuf\ComposerStager\Domain\Core\Stager\StagerInterface; +use PhpTuf\ComposerStager\Infrastructure\Factory\Path\PathFactoryInterface; +use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; /** * Defines a service to perform updates for modules and themes. @@ -23,11 +33,41 @@ class ExtensionUpdater extends Stage { * * @param \Drupal\package_manager\ComposerInspector $composerInspector * The Composer inspector service. - * @param mixed ...$arguments - * Additional arguments to pass to the parent constructor. + * @param \Drupal\package_manager\PathLocator $pathLocator + * The path locator service. + * @param \PhpTuf\ComposerStager\Domain\Core\Beginner\BeginnerInterface $beginner + * The beginner service. + * @param \PhpTuf\ComposerStager\Domain\Core\Stager\StagerInterface $stager + * The stager service. + * @param \PhpTuf\ComposerStager\Domain\Core\Committer\CommitterInterface $committer + * The committer service. + * @param \Drupal\Core\File\FileSystemInterface $fileSystem + * The file system service. + * @param \Symfony\Contracts\EventDispatcher\EventDispatcherInterface $eventDispatcher + * The event dispatcher service. + * @param \Drupal\Core\TempStore\SharedTempStoreFactory $tempStoreFactory + * The shared tempstore factory. + * @param \Drupal\Component\Datetime\TimeInterface $time + * The time service. + * @param \PhpTuf\ComposerStager\Infrastructure\Factory\Path\PathFactoryInterface $pathFactory + * The path factory service. + * @param \Drupal\package_manager\FailureMarker $failureMarker + * The failure marker service. */ - public function __construct(protected ComposerInspector $composerInspector, mixed ...$arguments) { - parent::__construct(...$arguments); + public function __construct( + protected ComposerInspector $composerInspector, + PathLocator $pathLocator, + BeginnerInterface $beginner, + StagerInterface $stager, + CommitterInterface $committer, + FileSystemInterface $fileSystem, + EventDispatcherInterface $eventDispatcher, + SharedTempStoreFactory $tempStoreFactory, + TimeInterface $time, + PathFactoryInterface $pathFactory, + FailureMarker $failureMarker, + ) { + parent::__construct($pathLocator, $beginner, $stager, $committer, $fileSystem, $eventDispatcher, $tempStoreFactory, $time, $pathFactory, $failureMarker); } /** diff --git a/package_manager/package_manager.services.yml b/package_manager/package_manager.services.yml index 04eedd84d03fe5131d4a9bc5de5bd264ca9d382a..dc1a3c984d157059d4c85bde6c5739ce661c0e9c 100644 --- a/package_manager/package_manager.services.yml +++ b/package_manager/package_manager.services.yml @@ -26,10 +26,13 @@ services: # Services provided to Drupal by Package Manager. package_manager.beginner: class: PhpTuf\ComposerStager\Domain\Core\Beginner\Beginner + PhpTuf\ComposerStager\Domain\Core\Beginner\BeginnerInterface: '@package_manager.beginner' package_manager.stager: class: PhpTuf\ComposerStager\Domain\Core\Stager\Stager + PhpTuf\ComposerStager\Domain\Core\Stager\StagerInterface: '@package_manager.stager' package_manager.committer: class: PhpTuf\ComposerStager\Domain\Core\Committer\Committer + PhpTuf\ComposerStager\Domain\Core\Committer\CommitterInterface: '@package_manager.committer' package_manager.path_locator: class: Drupal\package_manager\PathLocator arguments: @@ -115,6 +118,7 @@ services: class: Drupal\package_manager\Validator\StagedDBUpdateValidator tags: - { name: event_subscriber } + Drupal\package_manager\Validator\StagedDBUpdateValidator: '@package_manager.validator.staged_database_updates' package_manager.test_site_excluder: class: Drupal\package_manager\PathExcluder\TestSiteExcluder tags: diff --git a/package_manager/src/StatusCheckTrait.php b/package_manager/src/StatusCheckTrait.php index 5c1da0eac23efaf6a857d9bae3730bbaa15a6237..78e585b1d102d377d2f0139bfd4dafe2e1a4a62b 100644 --- a/package_manager/src/StatusCheckTrait.php +++ b/package_manager/src/StatusCheckTrait.php @@ -6,7 +6,7 @@ namespace Drupal\package_manager; use Drupal\package_manager\Event\CollectIgnoredPathsEvent; use Drupal\package_manager\Event\StatusCheckEvent; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; +use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; /** * Contains helper methods to run status checks on a stage. @@ -23,7 +23,7 @@ trait StatusCheckTrait { * * @param \Drupal\package_manager\Stage $stage * The stage to run the status check for. - * @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $event_dispatcher + * @param \Symfony\Contracts\EventDispatcher\EventDispatcherInterface $event_dispatcher * (optional) The event dispatcher service. * * @return \Drupal\package_manager\ValidationResult[] diff --git a/src/CronUpdater.php b/src/CronUpdater.php index e3624b7bbb0afc6ed605702ba8ae84608c501597..982e0c575e9f37a47d4f4c934c3b6fe91a516786 100644 --- a/src/CronUpdater.php +++ b/src/CronUpdater.php @@ -4,16 +4,27 @@ declare(strict_types = 1); namespace Drupal\automatic_updates; +use Drupal\Component\Datetime\TimeInterface; use Drupal\Core\Config\ConfigFactoryInterface; +use Drupal\Core\File\FileSystemInterface; use Drupal\Core\Mail\MailManagerInterface; use Drupal\Core\State\StateInterface; +use Drupal\Core\TempStore\SharedTempStoreFactory; use Drupal\Core\Url; +use Drupal\package_manager\ComposerInspector; use Drupal\package_manager\Exception\ApplyFailedException; use Drupal\package_manager\Exception\StageEventException; +use Drupal\package_manager\FailureMarker; +use Drupal\package_manager\PathLocator; use Drupal\package_manager\ProjectInfo; use Drupal\update\ProjectRelease; use GuzzleHttp\Psr7\Uri as GuzzleUri; +use PhpTuf\ComposerStager\Domain\Core\Beginner\BeginnerInterface; +use PhpTuf\ComposerStager\Domain\Core\Committer\CommitterInterface; +use PhpTuf\ComposerStager\Domain\Core\Stager\StagerInterface; +use PhpTuf\ComposerStager\Infrastructure\Factory\Path\PathFactoryInterface; use Symfony\Component\HttpFoundation\Response; +use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; /** * Defines a service that updates via cron. @@ -60,8 +71,28 @@ class CronUpdater extends Updater { * The state service. * @param \Drupal\Core\Config\ConfigFactoryInterface $configFactory * The config factory service. - * @param mixed ...$arguments - * Additional arguments to pass to the parent constructor. + * @param \Drupal\package_manager\ComposerInspector $composerInspector + * The Composer inspector service. + * @param \Drupal\package_manager\PathLocator $pathLocator + * The path locator service. + * @param \PhpTuf\ComposerStager\Domain\Core\Beginner\BeginnerInterface $beginner + * The beginner service. + * @param \PhpTuf\ComposerStager\Domain\Core\Stager\StagerInterface $stager + * The stager service. + * @param \PhpTuf\ComposerStager\Domain\Core\Committer\CommitterInterface $committer + * The committer service. + * @param \Drupal\Core\File\FileSystemInterface $fileSystem + * The file system service. + * @param \Symfony\Contracts\EventDispatcher\EventDispatcherInterface $eventDispatcher + * The event dispatcher service. + * @param \Drupal\Core\TempStore\SharedTempStoreFactory $tempStoreFactory + * The shared tempstore factory. + * @param \Drupal\Component\Datetime\TimeInterface $time + * The time service. + * @param \PhpTuf\ComposerStager\Infrastructure\Factory\Path\PathFactoryInterface $pathFactory + * The path factory service. + * @param \Drupal\package_manager\FailureMarker $failureMarker + * The failure marker service. */ public function __construct( protected ReleaseChooser $releaseChooser, @@ -69,9 +100,19 @@ class CronUpdater extends Updater { protected StatusCheckMailer $statusCheckMailer, protected StateInterface $state, protected ConfigFactoryInterface $configFactory, - mixed ...$arguments, + ComposerInspector $composerInspector, + PathLocator $pathLocator, + BeginnerInterface $beginner, + StagerInterface $stager, + CommitterInterface $committer, + FileSystemInterface $fileSystem, + EventDispatcherInterface $eventDispatcher, + SharedTempStoreFactory $tempStoreFactory, + TimeInterface $time, + PathFactoryInterface $pathFactory, + FailureMarker $failureMarker, ) { - parent::__construct(...$arguments); + parent::__construct($composerInspector, $pathLocator, $beginner, $stager, $committer, $fileSystem, $eventDispatcher, $tempStoreFactory, $time, $pathFactory, $failureMarker); } /** diff --git a/src/Updater.php b/src/Updater.php index bb08bb525a122c0f5e874355086a3fb68fb386ce..d1c47a80cc4bbdcc7ac917b5d59cdef4cfd6fccd 100644 --- a/src/Updater.php +++ b/src/Updater.php @@ -4,9 +4,19 @@ declare(strict_types = 1); namespace Drupal\automatic_updates; +use Drupal\Component\Datetime\TimeInterface; +use Drupal\Core\File\FileSystemInterface; use Drupal\Core\StringTranslation\TranslatableMarkup; +use Drupal\Core\TempStore\SharedTempStoreFactory; use Drupal\package_manager\ComposerInspector; +use Drupal\package_manager\FailureMarker; +use Drupal\package_manager\PathLocator; use Drupal\package_manager\Stage; +use PhpTuf\ComposerStager\Domain\Core\Beginner\BeginnerInterface; +use PhpTuf\ComposerStager\Domain\Core\Committer\CommitterInterface; +use PhpTuf\ComposerStager\Domain\Core\Stager\StagerInterface; +use PhpTuf\ComposerStager\Infrastructure\Factory\Path\PathFactoryInterface; +use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; /** * Defines a service to perform updates. @@ -23,11 +33,41 @@ class Updater extends Stage { * * @param \Drupal\package_manager\ComposerInspector $composerInspector * The Composer inspector service. - * @param mixed ...$arguments - * Additional arguments to pass to the parent constructor. + * @param \Drupal\package_manager\PathLocator $pathLocator + * The path locator service. + * @param \PhpTuf\ComposerStager\Domain\Core\Beginner\BeginnerInterface $beginner + * The beginner service. + * @param \PhpTuf\ComposerStager\Domain\Core\Stager\StagerInterface $stager + * The stager service. + * @param \PhpTuf\ComposerStager\Domain\Core\Committer\CommitterInterface $committer + * The committer service. + * @param \Drupal\Core\File\FileSystemInterface $fileSystem + * The file system service. + * @param \Symfony\Contracts\EventDispatcher\EventDispatcherInterface $eventDispatcher + * The event dispatcher service. + * @param \Drupal\Core\TempStore\SharedTempStoreFactory $tempStoreFactory + * The shared tempstore factory. + * @param \Drupal\Component\Datetime\TimeInterface $time + * The time service. + * @param \PhpTuf\ComposerStager\Infrastructure\Factory\Path\PathFactoryInterface $pathFactory + * The path factory service. + * @param \Drupal\package_manager\FailureMarker $failureMarker + * The failure marker service. */ - public function __construct(protected ComposerInspector $composerInspector, mixed ...$arguments) { - parent::__construct(...$arguments); + public function __construct( + protected ComposerInspector $composerInspector, + PathLocator $pathLocator, + BeginnerInterface $beginner, + StagerInterface $stager, + CommitterInterface $committer, + FileSystemInterface $fileSystem, + EventDispatcherInterface $eventDispatcher, + SharedTempStoreFactory $tempStoreFactory, + TimeInterface $time, + PathFactoryInterface $pathFactory, + FailureMarker $failureMarker, + ) { + parent::__construct($pathLocator, $beginner, $stager, $committer, $fileSystem, $eventDispatcher, $tempStoreFactory, $time, $pathFactory, $failureMarker); } /** diff --git a/src/Validation/StatusChecker.php b/src/Validation/StatusChecker.php index c98f561c2094a5b99144dc12dd7c14d0dded4a17..366c7e443786b190964b95721927cb7706f4d643 100644 --- a/src/Validation/StatusChecker.php +++ b/src/Validation/StatusChecker.php @@ -10,7 +10,7 @@ use Drupal\automatic_updates\Updater; use Drupal\Component\Datetime\TimeInterface; use Drupal\Core\KeyValueStore\KeyValueExpirableFactoryInterface; use Drupal\package_manager\Event\PostApplyEvent; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; +use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; /** @@ -34,7 +34,7 @@ final class StatusChecker implements EventSubscriberInterface { * The key/value expirable factory. * @param \Drupal\Component\Datetime\TimeInterface $time * The time service. - * @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $eventDispatcher + * @param \Symfony\Contracts\EventDispatcher\EventDispatcherInterface $eventDispatcher * The event dispatcher service. * @param \Drupal\automatic_updates\Updater $updater * The updater service.