function Recipe::validateKeysAreValidExtensionNames

Validates that the keys of an array are valid extension names.

Note that the keys do not have to be the names of extensions that are installed, or even extensions that exist. They just have to follow the form of a valid extension name.

Parameters

array $value: The array being validated.

\Symfony\Component\Validator\Context\ExecutionContextInterface $context: The validator execution context.

1 call to Recipe::validateKeysAreValidExtensionNames()
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 448

Class

Recipe
@internal This API is experimental.

Namespace

Drupal\Core\Recipe

Code

private static function validateKeysAreValidExtensionNames(array $value, ExecutionContextInterface $context) : void {
    $keys = array_keys($value);
    foreach ($keys as $key) {
        if (!preg_match(ExtensionDiscovery::PHP_FUNCTION_PATTERN, $key)) {
            $context->addViolation('%name is not a valid extension name.', [
                '%name' => $key,
            ]);
        }
    }
}

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