function PhpTufValidator::validate

Reacts to a stage event by validating PHP-TUF configuration as needed.

Parameters

\Drupal\package_manager\Event\PreOperationStageEvent $event: The event object.

File

core/modules/package_manager/src/Validator/PhpTufValidator.php, line 80

Class

PhpTufValidator
Validates that PHP-TUF is installed and correctly configured.

Namespace

Drupal\package_manager\Validator

Code

public function validate(PreOperationStageEvent $event) : void {
    $messages = $this->validateTuf($this->pathLocator
        ->getProjectRoot());
    if ($messages) {
        $event->addError($messages, $this->t('The active directory is not protected by PHP-TUF, which is required to use Package Manager securely.'));
    }
    $stage = $event->stage;
    if ($stage->stageDirectoryExists()) {
        $messages = $this->validateTuf($stage->getStageDirectory());
        if ($messages) {
            $event->addError($messages, $this->t('The stage directory is not protected by PHP-TUF, which is required to use Package Manager securely.'));
        }
    }
}

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