From 19760c80c5c6bfa8b7bb2b11a629b49bceda2c88 Mon Sep 17 00:00:00 2001 From: phenaproxima <phenaproxima@205645.no-reply.drupal.org> Date: Wed, 8 Jun 2022 14:47:20 +0000 Subject: [PATCH] Issue #3284530 by phenaproxima: Stage does not need the path factory to be injected --- automatic_updates.services.yml | 2 -- .../automatic_updates_extensions.services.yml | 1 - package_manager/src/PackageManagerUninstallValidator.php | 4 +--- package_manager/src/Stage.php | 8 +++----- .../package_manager_test_api/src/ApiController.php | 4 +--- .../tests/src/Kernel/PackageManagerKernelTestBase.php | 4 ++-- 6 files changed, 7 insertions(+), 16 deletions(-) diff --git a/automatic_updates.services.yml b/automatic_updates.services.yml index 5d0fc38d79..a5e5545c3a 100644 --- a/automatic_updates.services.yml +++ b/automatic_updates.services.yml @@ -26,7 +26,6 @@ services: - '@event_dispatcher' - '@tempstore.shared' - '@datetime.time' - - '@PhpTuf\ComposerStager\Infrastructure\Factory\Path\PathFactoryInterface' automatic_updates.cron_updater: class: Drupal\automatic_updates\CronUpdater arguments: @@ -41,7 +40,6 @@ services: - '@event_dispatcher' - '@tempstore.shared' - '@datetime.time' - - '@PhpTuf\ComposerStager\Infrastructure\Factory\Path\PathFactoryInterface' automatic_updates.staged_projects_validator: class: Drupal\automatic_updates\Validator\StagedProjectsValidator arguments: diff --git a/automatic_updates_extensions/automatic_updates_extensions.services.yml b/automatic_updates_extensions/automatic_updates_extensions.services.yml index 2e4867dab5..dea4d1ff45 100644 --- a/automatic_updates_extensions/automatic_updates_extensions.services.yml +++ b/automatic_updates_extensions/automatic_updates_extensions.services.yml @@ -11,7 +11,6 @@ services: - '@event_dispatcher' - '@tempstore.shared' - '@datetime.time' - - '@PhpTuf\ComposerStager\Infrastructure\Factory\Path\PathFactoryInterface' automatic_updates_extensions.validator.target_release: class: Drupal\automatic_updates_extensions\Validator\UpdateReleaseValidator tags: diff --git a/package_manager/src/PackageManagerUninstallValidator.php b/package_manager/src/PackageManagerUninstallValidator.php index 8348ed090d..dd9ab87607 100644 --- a/package_manager/src/PackageManagerUninstallValidator.php +++ b/package_manager/src/PackageManagerUninstallValidator.php @@ -4,7 +4,6 @@ namespace Drupal\package_manager; use Drupal\Core\Extension\ModuleUninstallValidatorInterface; use Drupal\Core\StringTranslation\StringTranslationTrait; -use PhpTuf\ComposerStager\Infrastructure\Factory\Path\PathFactoryInterface; use Symfony\Component\DependencyInjection\ContainerAwareInterface; use Symfony\Component\DependencyInjection\ContainerAwareTrait; @@ -29,8 +28,7 @@ class PackageManagerUninstallValidator implements ModuleUninstallValidatorInterf $this->container->get('file_system'), $this->container->get('event_dispatcher'), $this->container->get('tempstore.shared'), - $this->container->get('datetime.time'), - $this->container->get(PathFactoryInterface::class) + $this->container->get('datetime.time') ); if ($stage->isAvailable() || !$stage->isApplying()) { return []; diff --git a/package_manager/src/Stage.php b/package_manager/src/Stage.php index c8194d7ae4..9c04f552d3 100644 --- a/package_manager/src/Stage.php +++ b/package_manager/src/Stage.php @@ -24,7 +24,7 @@ use Drupal\package_manager\Exception\StageValidationException; 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 PhpTuf\ComposerStager\Infrastructure\Factory\Path\PathFactory; use PhpTuf\ComposerStager\Infrastructure\Value\PathList\PathList; use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; @@ -187,10 +187,8 @@ class Stage { * The shared tempstore factory. * @param \Drupal\Component\Datetime\TimeInterface $time * The time service. - * @param \PhpTuf\ComposerStager\Infrastructure\Factory\Path\PathFactoryInterface $path_factory - * The path factory service. */ - public function __construct(ConfigFactoryInterface $config_factory, PathLocator $path_locator, BeginnerInterface $beginner, StagerInterface $stager, CommitterInterface $committer, FileSystemInterface $file_system, EventDispatcherInterface $event_dispatcher, SharedTempStoreFactory $shared_tempstore, TimeInterface $time, PathFactoryInterface $path_factory) { + public function __construct(ConfigFactoryInterface $config_factory, PathLocator $path_locator, BeginnerInterface $beginner, StagerInterface $stager, CommitterInterface $committer, FileSystemInterface $file_system, EventDispatcherInterface $event_dispatcher, SharedTempStoreFactory $shared_tempstore, TimeInterface $time) { $this->configFactory = $config_factory; $this->pathLocator = $path_locator; $this->beginner = $beginner; @@ -200,7 +198,7 @@ class Stage { $this->eventDispatcher = $event_dispatcher; $this->time = $time; $this->tempStore = $shared_tempstore->get('package_manager_stage'); - $this->pathFactory = $path_factory; + $this->pathFactory = new PathFactory(); } /** diff --git a/package_manager/tests/modules/package_manager_test_api/src/ApiController.php b/package_manager/tests/modules/package_manager_test_api/src/ApiController.php index 2d586cdf6f..45eb27f0f8 100644 --- a/package_manager/tests/modules/package_manager_test_api/src/ApiController.php +++ b/package_manager/tests/modules/package_manager_test_api/src/ApiController.php @@ -5,7 +5,6 @@ namespace Drupal\package_manager_test_api; use Drupal\Core\Controller\ControllerBase; use Drupal\package_manager\PathLocator; use Drupal\package_manager\Stage; -use PhpTuf\ComposerStager\Infrastructure\Factory\Path\PathFactoryInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; @@ -55,8 +54,7 @@ class ApiController extends ControllerBase { $container->get('file_system'), $container->get('event_dispatcher'), $container->get('tempstore.shared'), - $container->get('datetime.time'), - $container->get(PathFactoryInterface::class) + $container->get('datetime.time') ); return new static( $stage, diff --git a/package_manager/tests/src/Kernel/PackageManagerKernelTestBase.php b/package_manager/tests/src/Kernel/PackageManagerKernelTestBase.php index c42d0bf025..7296d19205 100644 --- a/package_manager/tests/src/Kernel/PackageManagerKernelTestBase.php +++ b/package_manager/tests/src/Kernel/PackageManagerKernelTestBase.php @@ -107,8 +107,7 @@ abstract class PackageManagerKernelTestBase extends KernelTestBase { $this->container->get('file_system'), $this->container->get('event_dispatcher'), $this->container->get('tempstore.shared'), - $this->container->get('datetime.time'), - new TestPathFactory() + $this->container->get('datetime.time') ); } @@ -278,6 +277,7 @@ trait TestStageTrait { parent::__construct(...$arguments); $mirror = new \ReflectionClass(Stage::class); $this->tempStore->set($mirror->getConstant('TEMPSTORE_STAGING_ROOT_KEY'), PackageManagerKernelTestBase::$testStagingRoot); + $this->pathFactory = new TestPathFactory(); } /** -- GitLab