You are here

public function BlockContentEntityChangedConstraintValidator::validate in Drupal 10

Overrides EntityChangedConstraintValidator::validate

File

core/modules/block_content/src/Plugin/Validation/Constraint/BlockContentEntityChangedConstraintValidator.php, line 17

Class

BlockContentEntityChangedConstraintValidator
Validates the BlockContentEntityChanged constraint.

Namespace

Drupal\block_content\Plugin\Validation\Constraint

Code

public function validate($entity, Constraint $constraint) {

  // This prevents saving an update to the block via a host entity's form if
  // the host entity has had other changes made via the API instead of the
  // entity form, such as a revision revert. This is safe, for example, in the
  // Layout Builder the inline blocks are not saved until the whole layout is
  // saved, in which case Layout Builder forces a new revision for the block.
  // @see \Drupal\layout_builder\InlineBlockEntityOperations::handlePreSave.
  if ($entity instanceof BlockContentInterface && !$entity
    ->isReusable()) {
    return;
  }
  parent::validate($entity, $constraint);
}