From d55c360c36214ebdd42ce1d6e63b5f10bc8aed3c Mon Sep 17 00:00:00 2001 From: phenaproxima <phenaproxima@205645.no-reply.drupal.org> Date: Fri, 22 Oct 2021 17:11:20 +0000 Subject: [PATCH] Issue #3245376 by phenaproxima, tedbow: Move the path locator entirely to Package Manager --- automatic_updates.services.yml | 11 +++-------- src/PathLocator.php | 11 ----------- src/Validation/ReadinessValidationManager.php | 6 +++--- src/Validator/DiskSpaceValidator.php | 6 +++--- src/Validator/WritableFileSystemValidator.php | 6 +++--- tests/src/Functional/FileSystemOperationsTest.php | 2 +- .../ReadinessValidation/CoreComposerValidatorTest.php | 4 ++-- .../ReadinessValidation/DiskSpaceValidatorTest.php | 2 +- .../WritableFileSystemValidatorTest.php | 2 +- tests/src/Kernel/UpdaterTest.php | 2 +- 10 files changed, 18 insertions(+), 34 deletions(-) delete mode 100644 src/PathLocator.php diff --git a/automatic_updates.services.yml b/automatic_updates.services.yml index 38de671385..21b97e6d11 100644 --- a/automatic_updates.services.yml +++ b/automatic_updates.services.yml @@ -4,7 +4,7 @@ services: arguments: - '@keyvalue.expirable' - '@datetime.time' - - '@automatic_updates.path_locator' + - '@package_manager.path_locator' - '@event_dispatcher' - 24 automatic_updates.updater: @@ -46,7 +46,7 @@ services: automatic_updates.disk_space_validator: class: Drupal\automatic_updates\Validator\DiskSpaceValidator arguments: - - '@automatic_updates.path_locator' + - '@package_manager.path_locator' - '@string_translation' tags: - { name: event_subscriber } @@ -61,7 +61,7 @@ services: automatic_updates.validator.file_system_permissions: class: Drupal\automatic_updates\Validator\WritableFileSystemValidator arguments: - - '@automatic_updates.path_locator' + - '@package_manager.path_locator' - '%app.root%' - '@string_translation' tags: @@ -70,8 +70,3 @@ services: class: Drupal\automatic_updates\Validator\CoreComposerValidator tags: - { name: event_subscriber } - automatic_updates.path_locator: - class: Drupal\automatic_updates\PathLocator - arguments: - - '@config.factory' - - '%app.root%' diff --git a/src/PathLocator.php b/src/PathLocator.php deleted file mode 100644 index 3ba735edad..0000000000 --- a/src/PathLocator.php +++ /dev/null @@ -1,11 +0,0 @@ -<?php - -namespace Drupal\automatic_updates; - -use Drupal\package_manager\PathLocator as PackageManagerPathLocator; - -/** - * Computes file system paths that are needed for automatic updates. - */ -class PathLocator extends PackageManagerPathLocator { -} diff --git a/src/Validation/ReadinessValidationManager.php b/src/Validation/ReadinessValidationManager.php index 23ab82eefc..6f2a9bfd22 100644 --- a/src/Validation/ReadinessValidationManager.php +++ b/src/Validation/ReadinessValidationManager.php @@ -4,11 +4,11 @@ namespace Drupal\automatic_updates\Validation; use Drupal\automatic_updates\AutomaticUpdatesEvents; use Drupal\automatic_updates\Event\ReadinessCheckEvent; -use Drupal\automatic_updates\PathLocator; use Drupal\automatic_updates\UpdateRecommender; use Drupal\Component\Datetime\TimeInterface; use Drupal\Core\KeyValueStore\KeyValueExpirableFactoryInterface; use Drupal\package_manager\ComposerUtility; +use Drupal\package_manager\PathLocator; use Symfony\Component\EventDispatcher\EventDispatcherInterface; /** @@ -47,7 +47,7 @@ class ReadinessValidationManager { /** * The path locator service. * - * @var \Drupal\automatic_updates\PathLocator + * @var \Drupal\package_manager\PathLocator */ protected $pathLocator; @@ -58,7 +58,7 @@ class ReadinessValidationManager { * The key/value expirable factory. * @param \Drupal\Component\Datetime\TimeInterface $time * The time service. - * @param \Drupal\automatic_updates\PathLocator $path_locator + * @param \Drupal\package_manager\PathLocator $path_locator * The path locator service. * @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $dispatcher * The event dispatcher service. diff --git a/src/Validator/DiskSpaceValidator.php b/src/Validator/DiskSpaceValidator.php index 3bb25fbee9..9b53192ce0 100644 --- a/src/Validator/DiskSpaceValidator.php +++ b/src/Validator/DiskSpaceValidator.php @@ -4,12 +4,12 @@ namespace Drupal\automatic_updates\Validator; use Drupal\automatic_updates\AutomaticUpdatesEvents; use Drupal\automatic_updates\Event\UpdateEvent; -use Drupal\automatic_updates\PathLocator; use Drupal\automatic_updates\Validation\ValidationResult; use Drupal\Component\FileSystem\FileSystem; use Drupal\Component\Utility\Bytes; use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\Core\StringTranslation\TranslationInterface; +use Drupal\package_manager\PathLocator; use Symfony\Component\EventDispatcher\EventSubscriberInterface; /** @@ -22,14 +22,14 @@ class DiskSpaceValidator implements EventSubscriberInterface { /** * The path locator service. * - * @var \Drupal\automatic_updates\PathLocator + * @var \Drupal\package_manager\PathLocator */ protected $pathLocator; /** * Constructs a DiskSpaceValidator object. * - * @param \Drupal\automatic_updates\PathLocator $path_locator + * @param \Drupal\package_manager\PathLocator $path_locator * The path locator service. * @param \Drupal\Core\StringTranslation\TranslationInterface $translation * The translation service. diff --git a/src/Validator/WritableFileSystemValidator.php b/src/Validator/WritableFileSystemValidator.php index 4b564ace37..792a78da7b 100644 --- a/src/Validator/WritableFileSystemValidator.php +++ b/src/Validator/WritableFileSystemValidator.php @@ -4,10 +4,10 @@ namespace Drupal\automatic_updates\Validator; use Drupal\automatic_updates\AutomaticUpdatesEvents; use Drupal\automatic_updates\Event\UpdateEvent; -use Drupal\automatic_updates\PathLocator; use Drupal\automatic_updates\Validation\ValidationResult; use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\Core\StringTranslation\TranslationInterface; +use Drupal\package_manager\PathLocator; use Symfony\Component\EventDispatcher\EventSubscriberInterface; /** @@ -20,7 +20,7 @@ class WritableFileSystemValidator implements EventSubscriberInterface { /** * The path locator service. * - * @var \Drupal\automatic_updates\PathLocator + * @var \Drupal\package_manager\PathLocator */ protected $pathLocator; @@ -34,7 +34,7 @@ class WritableFileSystemValidator implements EventSubscriberInterface { /** * Constructs a WritableFileSystemValidator object. * - * @param \Drupal\automatic_updates\PathLocator $path_locator + * @param \Drupal\package_manager\PathLocator $path_locator * The path locator service. * @param string $app_root * The Drupal root. diff --git a/tests/src/Functional/FileSystemOperationsTest.php b/tests/src/Functional/FileSystemOperationsTest.php index 1e821229b4..fe42f99893 100644 --- a/tests/src/Functional/FileSystemOperationsTest.php +++ b/tests/src/Functional/FileSystemOperationsTest.php @@ -49,7 +49,7 @@ class FileSystemOperationsTest extends AutomaticUpdatesFunctionalTestBase { // active directory, and has a staging area within the site directory for // this test. $drupal_root = $this->getDrupalRoot(); - /** @var \Drupal\automatic_updates\PathLocator|\Prophecy\Prophecy\ObjectProphecy $locator */ + /** @var \Drupal\package_manager\PathLocator|\Prophecy\Prophecy\ObjectProphecy $locator */ $locator = $this->prophesize(PathLocator::class); $locator->getActiveDirectory()->willReturn(__DIR__ . '/../../fixtures/fake-site'); $this->stageDir = implode(DIRECTORY_SEPARATOR, [ diff --git a/tests/src/Kernel/ReadinessValidation/CoreComposerValidatorTest.php b/tests/src/Kernel/ReadinessValidation/CoreComposerValidatorTest.php index b2eb7d8166..ceadb6b8c2 100644 --- a/tests/src/Kernel/ReadinessValidation/CoreComposerValidatorTest.php +++ b/tests/src/Kernel/ReadinessValidation/CoreComposerValidatorTest.php @@ -2,9 +2,9 @@ namespace Drupal\Tests\automatic_updates\Kernel\ReadinessValidation; -use Drupal\automatic_updates\PathLocator; use Drupal\automatic_updates\Validation\ValidationResult; use Drupal\Core\DependencyInjection\ContainerBuilder; +use Drupal\package_manager\PathLocator; use Drupal\Tests\automatic_updates\Kernel\AutomaticUpdatesKernelTestBase; /** @@ -38,7 +38,7 @@ class CoreComposerValidatorTest extends AutomaticUpdatesKernelTestBase { // Point to a valid composer.json with no requirements. $locator = $this->prophesize(PathLocator::class); $locator->getActiveDirectory()->willReturn(__DIR__ . '/../../../fixtures/project_staged_validation/no_core_requirements'); - $this->container->set('automatic_updates.path_locator', $locator->reveal()); + $this->container->set('package_manager.path_locator', $locator->reveal()); $error = ValidationResult::createError([ 'Drupal core does not appear to be required in the project-level composer.json.', diff --git a/tests/src/Kernel/ReadinessValidation/DiskSpaceValidatorTest.php b/tests/src/Kernel/ReadinessValidation/DiskSpaceValidatorTest.php index e821121ac7..35753da2b2 100644 --- a/tests/src/Kernel/ReadinessValidation/DiskSpaceValidatorTest.php +++ b/tests/src/Kernel/ReadinessValidation/DiskSpaceValidatorTest.php @@ -151,7 +151,7 @@ class DiskSpaceValidatorTest extends AutomaticUpdatesKernelTestBase { * @dataProvider providerDiskSpaceValidation */ public function testDiskSpaceValidation(bool $shared_disk, array $free_space, array $expected_results): void { - $path_locator = $this->prophesize('\Drupal\automatic_updates\PathLocator'); + $path_locator = $this->prophesize('\Drupal\package_manager\PathLocator'); $path_locator->getProjectRoot()->willReturn('root'); $path_locator->getVendorDirectory()->willReturn('vendor'); diff --git a/tests/src/Kernel/ReadinessValidation/WritableFileSystemValidatorTest.php b/tests/src/Kernel/ReadinessValidation/WritableFileSystemValidatorTest.php index f49522a5f3..a89547df21 100644 --- a/tests/src/Kernel/ReadinessValidation/WritableFileSystemValidatorTest.php +++ b/tests/src/Kernel/ReadinessValidation/WritableFileSystemValidatorTest.php @@ -2,10 +2,10 @@ namespace Drupal\Tests\automatic_updates\Kernel\ReadinessValidation; -use Drupal\automatic_updates\PathLocator; use Drupal\automatic_updates\Validation\ValidationResult; use Drupal\automatic_updates\Validator\WritableFileSystemValidator; use Drupal\Core\DependencyInjection\ContainerBuilder; +use Drupal\package_manager\PathLocator; use Drupal\Tests\automatic_updates\Kernel\AutomaticUpdatesKernelTestBase; use org\bovigo\vfs\vfsStream; diff --git a/tests/src/Kernel/UpdaterTest.php b/tests/src/Kernel/UpdaterTest.php index ed9eeb51df..6b3f47497d 100644 --- a/tests/src/Kernel/UpdaterTest.php +++ b/tests/src/Kernel/UpdaterTest.php @@ -2,7 +2,7 @@ namespace Drupal\Tests\automatic_updates\Kernel; -use Drupal\automatic_updates\PathLocator; +use Drupal\package_manager\PathLocator; /** * @coversDefaultClass \Drupal\automatic_updates\Updater -- GitLab