getBlockContentEntity example

BlockContentEvents::BLOCK_CONTENT_GET_DEPENDENCY => 'onGetDependency',
    ];
  }

  /** * Handles the BlockContentEvents::INLINE_BLOCK_GET_DEPENDENCY event. * * @param \Drupal\block_content\Event\BlockContentGetDependencyEvent $event * The event. */
  public function onGetDependency(BlockContentGetDependencyEvent $event) {
    if ($dependency = $this->getInlineBlockDependency($event->getBlockContentEntity())) {
      $event->setAccessDependency($dependency);
    }
  }

  /** * Get the access dependency of an inline block. * * If the block is used in an entity that entity will be returned as the * dependency. * * For revisionable entities the entity will only be returned if it is used in * the latest revision of the entity. For inline blocks that are not used in * the latest revision but are used in a previous revision the entity will not * be returned because calling * \Drupal\Core\Access\AccessibleInterface::access() will only check access on * the latest revision. Therefore if the previous revision of the entity was * returned as the dependency access would be granted to inline block * regardless of whether the user has access to the revision in which the * inline block was used. * * @param \Drupal\block_content\BlockContentInterface $block_content * The block content entity. * * @return \Drupal\Core\Entity\EntityInterface|null * Returns the layout dependency. * * @see \Drupal\block_content\BlockContentAccessControlHandler::checkAccess() * @see \Drupal\layout_builder\EventSubscriber\BlockComponentRenderArray::onBuildRender() */
Home | Imprint | This part of the site doesn't use cookies.