function Recipe::validateExtensionIsAvailable
Same name in other branches
- 11.x core/lib/Drupal/Core/Recipe/Recipe.php \Drupal\Core\Recipe\Recipe::validateExtensionIsAvailable()
Validates that the value is an available module/theme (installed or not).
Parameters
string $value: The value to validate.
\Symfony\Component\Validator\Context\ExecutionContextInterface $context: The validator execution context.
See also
\Drupal\Core\Extension\ExtensionList::getAllAvailableInfo()
1 call to Recipe::validateExtensionIsAvailable()
- 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 217
Class
- Recipe
- @internal This API is experimental.
Namespace
Drupal\Core\RecipeCode
private static function validateExtensionIsAvailable(string $value, ExecutionContextInterface $context) : void {
$name = Dependency::createFromString($value)->getName();
$all_available = \Drupal::service(ModuleExtensionList::class)->getAllAvailableInfo() + \Drupal::service(ThemeExtensionList::class)->getAllAvailableInfo();
if (!array_key_exists($name, $all_available)) {
$context->addViolation('"%extension" is not a known module or theme.', [
'%extension' => $name,
]);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.