SetInlineBlockDependency
class SetInlineBlockDependency implements EventSubscriberInterface (View source)
| internal | Tagged services are internal. |
An event subscriber that returns an access dependency for inline blocks.
When used within the layout builder the access dependency for inline blocks will be explicitly set but if access is evaluated outside of the layout builder then the dependency may not have been set.
A known example of when the access dependency will not have been set is when determining 'view' or 'download' access to a file entity that is attached to a content block via a field that is using the private file system. The file access handler will evaluate access on the content block without setting the dependency.
Traits
Methods to help with entities using the layout builder.
Properties
| protected SectionStorageManagerInterface | $sectionStorageManager | The section storage manager. |
from LayoutEntityHelperTrait |
| protected EntityTypeManagerInterface | $entityTypeManager | The entity type manager. |
|
| protected Connection | $database | The database connection. |
|
| protected InlineBlockUsageInterface | $usage | The inline block usage service. |
Methods
Gets revision IDs for layout sections.
Gets components that have Inline Block plugins.
Determines if the original entity used the default section storage.
Constructs SetInlineBlockDependency object.
{@inheritdoc}
Handles the BlockContentEvents::INLINE_BLOCK_GET_DEPENDENCY event.
Get the access dependency of an inline block.
Determines if a block content revision is used in an entity.
Details
protected bool
isLayoutCompatibleEntity(EntityInterface $entity)
Determines if an entity can have a layout.
protected int[]
getInlineBlockRevisionIdsInSections(array $sections)
Gets revision IDs for layout sections.
protected Section[]
getEntitySections(EntityInterface $entity)
Gets the sections for an entity if any.
protected SectionComponent[]
getInlineBlockComponents(array $sections)
Gets components that have Inline Block plugins.
protected SectionStorageInterface|null
getSectionStorageForEntity(EntityInterface $entity)
Gets the section storage for an entity.
protected bool
originalEntityUsesDefaultStorage(EntityInterface $entity)
Determines if the original entity used the default section storage.
This method can be used during the entity save process to determine whether $entity->original is set and used the default section storage plugin as determined by ::getSectionStorageForEntity().
__construct(EntityTypeManagerInterface $entity_type_manager, Connection $database, InlineBlockUsageInterface $usage, SectionStorageManagerInterface $section_storage_manager)
Constructs SetInlineBlockDependency object.
static
getSubscribedEvents()
{@inheritdoc}
onGetDependency(BlockContentGetDependencyEvent $event)
Handles the BlockContentEvents::INLINE_BLOCK_GET_DEPENDENCY event.
protected EntityInterface|null
getInlineBlockDependency(BlockContentInterface $block_content)
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.
protected bool
isBlockRevisionUsedInEntity(EntityInterface $layout_entity, BlockContentInterface $block_content)
Determines if a block content revision is used in an entity.