class ImmutablePropertiesConstraint
Same name and namespace in other branches
- 11.x core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/ImmutablePropertiesConstraint.php \Drupal\Core\Entity\Plugin\Validation\Constraint\ImmutablePropertiesConstraint
- 10 core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/ImmutablePropertiesConstraint.php \Drupal\Core\Entity\Plugin\Validation\Constraint\ImmutablePropertiesConstraint
Checks if config entity properties have been changed.
Attributes
#[Constraint(id: 'ImmutableProperties', label: new TranslatableMarkup('Properties are unchanged', [], [
'context' => 'Validation',
]), type: [
'entity',
])]
Hierarchy
- class \Drupal\Core\Entity\Plugin\Validation\Constraint\ImmutablePropertiesConstraint extends \Symfony\Component\Validator\Constraint
Expanded class hierarchy of ImmutablePropertiesConstraint
2 files declare their use of ImmutablePropertiesConstraint
- ConstraintFactoryTest.php in core/
tests/ Drupal/ KernelTests/ Core/ Validation/ ConstraintFactoryTest.php - ImmutablePropertiesConstraintValidatorTest.php in core/
tests/ Drupal/ KernelTests/ Core/ Entity/ ImmutablePropertiesConstraintValidatorTest.php
File
-
core/
lib/ Drupal/ Core/ Entity/ Plugin/ Validation/ Constraint/ ImmutablePropertiesConstraint.php, line 15
Namespace
Drupal\Core\Entity\Plugin\Validation\ConstraintView source
class ImmutablePropertiesConstraint extends SymfonyConstraint {
/**
* The names of the immutable properties.
*
* @var string[]
*/
public array $properties = [];
public function __construct(mixed $options = NULL, ?array $properties = NULL, public string $message = "The '@name' property cannot be changed.", ?array $groups = NULL, mixed $payload = NULL) {
parent::__construct($options, $groups, $payload);
$this->properties = $properties ?? $this->properties;
}
/**
* {@inheritdoc}
*/
public function getDefaultOption() : ?string {
return 'properties';
}
/**
* {@inheritdoc}
*/
public function getRequiredOptions() : array {
return [
'properties',
];
}
}
Members
| Title Sort descending | Modifiers | Object type | Summary |
|---|---|---|---|
| ImmutablePropertiesConstraint::$properties | public | property | The names of the immutable properties. |
| ImmutablePropertiesConstraint::getDefaultOption | public | function | |
| ImmutablePropertiesConstraint::getRequiredOptions | public | function | |
| ImmutablePropertiesConstraint::__construct | public | function | #[HasNamedArguments] |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.