trait BaseRequirementValidatorTrait

Provides methods for base requirement validators.

This trait should only be used by validators that check base requirements, which means they run before \Drupal\package_manager\Validator\BaseRequirementsFulfilledValidator.

Validators which use this trait should NOT stop event propagation.

Hierarchy

See also

\Drupal\package_manager\Validator\BaseRequirementsFulfilledValidator

1 file declares its use of BaseRequirementValidatorTrait
BaseRequirementsFulfilledValidatorTest.php in core/modules/package_manager/tests/src/Kernel/BaseRequirementsFulfilledValidatorTest.php

File

core/modules/package_manager/src/Validator/BaseRequirementValidatorTrait.php, line 24

Namespace

Drupal\package_manager\Validator
View source
trait BaseRequirementValidatorTrait {
    
    /**
     * Validates base requirements.
     *
     * @param \Drupal\package_manager\Event\PreOperationStageEvent $event
     *   The event being handled.
     */
    public abstract function validate(PreOperationStageEvent $event) : void;
    
    /**
     * Implements EventSubscriberInterface::getSubscribedEvents().
     */
    public static function getSubscribedEvents() : array {
        // Always run before the BaseRequirementsFulfilledValidator.
        // @see \Drupal\package_manager\Validator\BaseRequirementsFulfilledValidator
        $priority = BaseRequirementsFulfilledValidator::PRIORITY + 10;
        return [
            PreCreateEvent::class => [
                'validate',
                $priority,
            ],
            PreRequireEvent::class => [
                'validate',
                $priority,
            ],
            PreApplyEvent::class => [
                'validate',
                $priority,
            ],
            StatusCheckEvent::class => [
                'validate',
                $priority,
            ],
        ];
    }

}

Members

Title Sort descending Modifiers Object type Summary Overrides
BaseRequirementValidatorTrait::getSubscribedEvents public static function Implements EventSubscriberInterface::getSubscribedEvents().
BaseRequirementValidatorTrait::validate abstract public function Validates base requirements. 8

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.