Skip to content
Snippets Groups Projects
Commit de9413f4 authored by Ted Bowman's avatar Ted Bowman
Browse files

Issue #3409519: PackageManagerUninstallValidator needs to use dependency injection to pass on 11.x

parent ee1286b9
No related branches found
No related tags found
No related merge requests found
......@@ -138,9 +138,8 @@ services:
Drupal\package_manager\PackageManagerUninstallValidator:
tags:
- { name: module_install.uninstall_validator }
parent: container.trait
calls:
- ['setContainer', ['@service_container']]
arguments:
$eventDispatcher: '@event_dispatcher'
lazy: true
Drupal\package_manager\Validator\SettingsValidator:
tags:
......
......@@ -4,15 +4,16 @@ declare(strict_types = 1);
namespace Drupal\package_manager;
use Drupal\Component\Datetime\TimeInterface;
use Drupal\Core\Extension\ModuleUninstallValidatorInterface;
use Drupal\Core\Queue\QueueFactory;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\Core\TempStore\SharedTempStoreFactory;
use PhpTuf\ComposerStager\API\Core\BeginnerInterface;
use PhpTuf\ComposerStager\API\Core\CommitterInterface;
use PhpTuf\ComposerStager\API\Core\StagerInterface;
use PhpTuf\ComposerStager\API\Path\Factory\PathFactoryInterface;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
/**
* Prevents any module from being uninstalled if update is in process.
......@@ -22,26 +23,62 @@ use Symfony\Component\DependencyInjection\ContainerAwareTrait;
* at any time without warning. External code should not interact with this
* class.
*/
final class PackageManagerUninstallValidator implements ModuleUninstallValidatorInterface, ContainerAwareInterface {
final class PackageManagerUninstallValidator implements ModuleUninstallValidatorInterface {
use ContainerAwareTrait;
use StringTranslationTrait;
/**
* Constructs a new PackageManagerUninstallValidator object.
*
* @param \Drupal\package_manager\PathLocator $pathLocator
* The path locator service.
* @param \PhpTuf\ComposerStager\API\Core\BeginnerInterface $beginner
* The beginner service.
* @param \PhpTuf\ComposerStager\API\Core\StagerInterface $stager
* The stager service.
* @param \PhpTuf\ComposerStager\API\Core\CommitterInterface $committer
* The committer service.
* @param \Drupal\Core\Queue\QueueFactory $queueFactory
* The queue factory service.
* @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $eventDispatcher
* The event dispatcher service.
* @param \Drupal\Core\TempStore\SharedTempStoreFactory $sharedTempStoreFactory
* The shared temp store factory service.
* @param \Drupal\Component\Datetime\TimeInterface $time
* The time service.
* @param \PhpTuf\ComposerStager\API\Path\Factory\PathFactoryInterface $pathFactory
* The path factory service.
* @param \Drupal\package_manager\FailureMarker $failureMarker
* The failure marker service.
*/
public function __construct(
private readonly PathLocator $pathLocator,
private readonly BeginnerInterface $beginner,
private readonly StagerInterface $stager,
private readonly CommitterInterface $committer,
private readonly QueueFactory $queueFactory,
private readonly EventDispatcherInterface $eventDispatcher,
private readonly SharedTempStoreFactory $sharedTempStoreFactory,
private readonly TimeInterface $time,
private readonly PathFactoryInterface $pathFactory,
private readonly FailureMarker $failureMarker
) {}
/**
* {@inheritdoc}
*/
public function validate($module) {
$stage = new class(
$this->container->get(PathLocator::class),
$this->container->get(BeginnerInterface::class),
$this->container->get(StagerInterface::class),
$this->container->get(CommitterInterface::class),
$this->container->get(QueueFactory::class),
$this->container->get('event_dispatcher'),
$this->container->get('tempstore.shared'),
$this->container->get('datetime.time'),
$this->container->get(PathFactoryInterface::class),
$this->container->get(FailureMarker::class)) extends StageBase {};
$this->pathLocator,
$this->beginner,
$this->stager,
$this->committer,
$this->queueFactory,
$this->eventDispatcher,
$this->sharedTempStoreFactory,
$this->time,
$this->pathFactory,
$this->failureMarker) extends StageBase {};
if ($stage->isAvailable() || !$stage->isApplying()) {
return [];
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment