function Recipe::validateConfigActions
Same name in other branches
- 11.x core/lib/Drupal/Core/Recipe/Recipe.php \Drupal\Core\Recipe\Recipe::validateConfigActions()
Validates that the corresponding extension is enabled for a config action.
Parameters
mixed $value: The config action; not used.
\Symfony\Component\Validator\Context\ExecutionContextInterface $context: The validator execution context.
string $include_path: The recipe's include path.
1 call to Recipe::validateConfigActions()
- Recipe::parse in core/
lib/ Drupal/ Core/ Recipe/ Recipe.php - Parses and validates a recipe.yml file.
File
-
core/
lib/ Drupal/ Core/ Recipe/ Recipe.php, line 259
Class
- Recipe
- @internal This API is experimental.
Namespace
Drupal\Core\RecipeCode
private static function validateConfigActions(mixed $value, ExecutionContextInterface $context, string $include_path) : void {
$config_name = str_replace([
'[config][actions]',
'[',
']',
], '', $context->getPropertyPath());
[
$config_provider,
] = explode('.', $config_name);
if ($config_provider === 'core') {
return;
}
$recipe_being_validated = $context->getRoot();
assert(is_array($recipe_being_validated));
$configurator = new RecipeConfigurator($recipe_being_validated['recipes'] ?? [], $include_path);
/** @var \Drupal\Core\Extension\ModuleExtensionList $module_list */
$module_list = \Drupal::service('extension.list.module');
// The config provider must either be an already-installed module or theme,
// or an extension being installed by this recipe or a recipe it depends on.
$all_extensions = [
array_keys($module_list->getAllInstalledInfo()),
array_keys(\Drupal::service('extension.list.theme')->getAllInstalledInfo()),
$recipe_being_validated['install'] ?? [],
$configurator->listAllExtensions(),
];
// Explicitly treat required modules as installed, even if Drupal isn't
// installed yet, because we know they WILL be installed.
foreach ($module_list->getAllAvailableInfo() as $name => $info) {
if (!empty($info['required'])) {
$all_extensions[] = $name;
}
}
if (!in_array($config_provider, $all_extensions, TRUE)) {
$context->addViolation('Config actions cannot be applied to %config_name because the %config_provider extension is not installed, and is not installed by this recipe or any of the recipes it depends on.', [
'%config_name' => $config_name,
'%config_provider' => $config_provider,
]);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.