class ExtensionAvailableConstraint
Same name and namespace in other branches
- 11.x core/lib/Drupal/Core/Extension/Plugin/Validation/Constraint/ExtensionAvailableConstraint.php \Drupal\Core\Extension\Plugin\Validation\Constraint\ExtensionAvailableConstraint
Check if an extension (module, theme, or profile) is available.
Attributes
#[Constraint(id: 'ExtensionAvailable', label: new TranslatableMarkup('Extension is available', [], [
'context' => 'Validation',
]))]
Hierarchy
- class \Drupal\Core\Extension\Plugin\Validation\Constraint\ExtensionAvailableConstraint extends \Symfony\Component\Validator\Constraint
Expanded class hierarchy of ExtensionAvailableConstraint
2 files declare their use of ExtensionAvailableConstraint
- ConstraintFactoryTest.php in core/
tests/ Drupal/ KernelTests/ Core/ Validation/ ConstraintFactoryTest.php - ExtensionAvailableConstraintValidatorTest.php in core/
tests/ Drupal/ KernelTests/ Core/ Extension/ ExtensionAvailableConstraintValidatorTest.php
File
-
core/
lib/ Drupal/ Core/ Extension/ Plugin/ Validation/ Constraint/ ExtensionAvailableConstraint.php, line 15
Namespace
Drupal\Core\Extension\Plugin\Validation\ConstraintView source
class ExtensionAvailableConstraint extends SymfonyConstraint {
/**
* The type of extension to look for. Can be 'module', 'theme' or 'profile'.
*
* @var string
*/
public string $type;
public function __construct(mixed $options = NULL, ?string $type = NULL, public string $moduleNotExistsMessage = "Module '@name' is not available.", public string $themeNotExistsMessage = "Theme '@name' is not available.", public string $profileNotExistsMessage = "Profile '@name' is not available.", public string $couldNotLoadProfileToCheckExtension = "Profile '@profile' could not be loaded to check if the extension '@extension' is available.", ?array $groups = NULL, mixed $payload = NULL) {
parent::__construct($options, $groups, $payload);
$this->type = $type ?? $this->type;
}
/**
* {@inheritdoc}
*/
public function getRequiredOptions() : array {
return [
'type',
];
}
/**
* {@inheritdoc}
*/
public function getDefaultOption() : ?string {
return 'type';
}
}
Members
| Title Sort descending | Modifiers | Object type | Summary |
|---|---|---|---|
| ExtensionAvailableConstraint::$type | public | property | The type of extension to look for. Can be 'module', 'theme' or 'profile'. |
| ExtensionAvailableConstraint::getDefaultOption | public | function | |
| ExtensionAvailableConstraint::getRequiredOptions | public | function | |
| ExtensionAvailableConstraint::__construct | public | function | #[HasNamedArguments] |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.