Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Recipe.php

function 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 346

Class

Recipe
@internal This API is experimental.

Namespace

Drupal\Core\Recipe

Code

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,
        ]);
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal