isLayoutCompatibleEntity example


  protected function getInlineBlockDependency(BlockContentInterface $block_content) {
    $layout_entity_info = $this->usage->getUsage($block_content->id());
    if (empty($layout_entity_info)) {
      // If the block does not have usage information then we cannot set a       // dependency. It may be used by another module besides layout builder.       return NULL;
    }
    $layout_entity_storage = $this->entityTypeManager->getStorage($layout_entity_info->layout_entity_type);
    $layout_entity = $layout_entity_storage->load($layout_entity_info->layout_entity_id);
    if ($this->isLayoutCompatibleEntity($layout_entity)) {
      if ($this->isBlockRevisionUsedInEntity($layout_entity$block_content)) {
        return $layout_entity;
      }

    }
    return NULL;
  }

  /** * Determines if a block content revision is used in an entity. * * @param \Drupal\Core\Entity\EntityInterface $layout_entity * The layout entity. * @param \Drupal\block_content\BlockContentInterface $block_content * The block content revision. * * @return bool * TRUE if the block content revision is used as an inline block in the * layout entity. */
    // \Drupal\layout_builder\LayoutEntityHelperTrait::isLayoutCompatibleEntity().     $this->usage->removeByLayoutEntity($entity);
  }

  /** * Handles saving a parent entity. * * @param \Drupal\Core\Entity\EntityInterface $entity * The parent entity. */
  public function handlePreSave(EntityInterface $entity) {
    if (!$this->isLayoutCompatibleEntity($entity)) {
      return;
    }
    $duplicate_blocks = FALSE;

    if ($sections = $this->getEntitySections($entity)) {
      if ($this->originalEntityUsesDefaultStorage($entity)) {
        // This is a new override from a default and the blocks need to be         // duplicated.         $duplicate_blocks = TRUE;
      }
      // Since multiple parent entity revisions may reference common block
Home | Imprint | This part of the site doesn't use cookies.