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

Breadcrumb

  1. Drupal Core 11.1.x

BlockContentEntityChangedConstraintValidator.php

Namespace

Drupal\block_content\Plugin\Validation\Constraint

File

core/modules/block_content/src/Plugin/Validation/Constraint/BlockContentEntityChangedConstraintValidator.php

View source
<?php

namespace Drupal\block_content\Plugin\Validation\Constraint;

use Drupal\block_content\BlockContentInterface;
use Drupal\Core\Entity\Plugin\Validation\Constraint\EntityChangedConstraintValidator;
use Symfony\Component\Validator\Constraint;

/**
 * Validates the BlockContentEntityChanged constraint.
 */
class BlockContentEntityChangedConstraintValidator extends EntityChangedConstraintValidator {
    
    /**
     * {@inheritdoc}
     */
    public function validate($entity, Constraint $constraint) : void {
        // 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);
    }

}

Classes

Title Deprecated Summary
BlockContentEntityChangedConstraintValidator Validates the BlockContentEntityChanged constraint.

API Navigation

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