function StageNotInActiveValidator::validate

Check if staging root is a subdirectory of active.

Overrides BaseRequirementValidatorTrait::validate

File

core/modules/package_manager/src/Validator/StageNotInActiveValidator.php, line 34

Class

StageNotInActiveValidator
Validates staging root is not a subdirectory of active.

Namespace

Drupal\package_manager\Validator

Code

public function validate(PreOperationStageEvent $event) : void {
    $project_root = $this->pathLocator
        ->getProjectRoot();
    $staging_root = $this->pathLocator
        ->getStagingRoot();
    if (str_starts_with($staging_root, $project_root)) {
        $message = $this->t("Stage directory is a subdirectory of the active directory.");
        $event->addError([
            $message,
        ]);
    }
}

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