Skip to content
Snippets Groups Projects

Resolve #3409519

1 unresolved thread
Files
2
@@ -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 {
Please register or sign in to reply
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 [];
}
Loading