class EntityChangedConstraintValidator in Zircon Profile 8.0
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityChangedConstraintValidator.php \Drupal\Core\Entity\Plugin\Validation\Constraint\EntityChangedConstraintValidator
Validates the EntityChanged constraint.
Hierarchy
- class \Symfony\Component\Validator\ConstraintValidator implements ConstraintValidatorInterface
- class \Drupal\Core\Entity\Plugin\Validation\Constraint\EntityChangedConstraintValidator
Expanded class hierarchy of EntityChangedConstraintValidator
File
- core/
lib/ Drupal/ Core/ Entity/ Plugin/ Validation/ Constraint/ EntityChangedConstraintValidator.php, line 16 - Contains \Drupal\Core\Entity\Plugin\Validation\Constraint\EntityChangedConstraintValidator.
Namespace
Drupal\Core\Entity\Plugin\Validation\ConstraintView source
class EntityChangedConstraintValidator extends ConstraintValidator {
/**
* {@inheritdoc}
*/
public function validate($entity, Constraint $constraint) {
if (isset($entity)) {
/** @var \Drupal\Core\Entity\EntityInterface $entity */
if (!$entity
->isNew()) {
$saved_entity = \Drupal::entityManager()
->getStorage($entity
->getEntityTypeId())
->loadUnchanged($entity
->id());
// A change to any other translation must add a violation to the current
// translation because there might be untranslatable shared fields.
if ($saved_entity && $saved_entity
->getChangedTimeAcrossTranslations() > $entity
->getChangedTimeAcrossTranslations()) {
$this->context
->addViolation($constraint->message);
}
}
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ConstraintValidator:: |
protected | property | 3 | |
ConstraintValidator:: |
protected | function | Wrapper for {@link ExecutionContextInterface::buildViolation} that supports the 2.4 context API. | |
ConstraintValidator:: |
protected | function | Wrapper for {@link ExecutionContextInterface::buildViolation} that supports the 2.4 context API. | |
ConstraintValidator:: |
protected | function | Returns a string representation of the type of the value. | |
ConstraintValidator:: |
protected | function | Returns a string representation of the value. | |
ConstraintValidator:: |
protected | function | Returns a string representation of a list of values. | |
ConstraintValidator:: |
public | function |
Initializes the constraint validator. Overrides ConstraintValidatorInterface:: |
1 |
ConstraintValidator:: |
constant | Whether to cast objects with a "__toString()" method to strings. | ||
ConstraintValidator:: |
constant | Whether to format {@link \DateTime} objects as RFC-3339 dates ("Y-m-d H:i:s"). | ||
EntityChangedConstraintValidator:: |
public | function |
Checks if the passed value is valid. Overrides ConstraintValidatorInterface:: |