function DuplicateInfoFileValidator::validate
Validates the stage does not have duplicate info.yml not present in active.
File
-
core/
modules/ package_manager/ src/ Validator/ DuplicateInfoFileValidator.php, line 31
Class
- DuplicateInfoFileValidator
- Validates the stage does not have duplicate info.yml not present in active.
Namespace
Drupal\package_manager\ValidatorCode
public function validate(PreApplyEvent $event) : void {
$active_dir = $this->pathLocator
->getProjectRoot();
$stage_dir = $event->stage
->getStageDirectory();
$active_info_files = $this->findInfoFiles($active_dir);
$stage_info_files = $this->findInfoFiles($stage_dir);
foreach ($stage_info_files as $stage_info_file => $stage_info_count) {
if (isset($active_info_files[$stage_info_file])) {
// Check if stage directory has more info.yml files matching
// $stage_info_file than in the active directory.
if ($stage_info_count > $active_info_files[$stage_info_file]) {
$event->addError([
$this->t('The stage directory has @stage_count instances of @stage_info_file as compared to @active_count in the active directory. This likely indicates that a duplicate extension was installed.', [
'@stage_info_file' => $stage_info_file,
'@stage_count' => $stage_info_count,
'@active_count' => $active_info_files[$stage_info_file],
]),
]);
}
}
elseif ($stage_info_count > 1) {
$event->addError([
$this->t('The stage directory has @stage_count instances of @stage_info_file. This likely indicates that a duplicate extension was installed.', [
'@stage_info_file' => $stage_info_file,
'@stage_count' => $stage_info_count,
]),
]);
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.