class BlockRepository implements BlockRepositoryInterface (View source)

Provides a repository for Block config entities.

Properties

protected EntityStorageInterface $blockStorage

The block storage.

protected ThemeManagerInterface $themeManager

The theme manager.

protected ContextHandlerInterface $contextHandler

The context handler.

Methods

__construct(EntityTypeManagerInterface $entity_type_manager, ThemeManagerInterface $theme_manager, ContextHandlerInterface $context_handler)

Constructs a new BlockRepository.

array
getVisibleBlocksPerRegion(array $cacheable_metadata = [])

Returns an array of regions and their block entities.

Details

__construct(EntityTypeManagerInterface $entity_type_manager, ThemeManagerInterface $theme_manager, ContextHandlerInterface $context_handler)

Constructs a new BlockRepository.

Parameters

EntityTypeManagerInterface $entity_type_manager

The entity type manager service.

ThemeManagerInterface $theme_manager

The theme manager.

ContextHandlerInterface $context_handler

The plugin context handler.

array getVisibleBlocksPerRegion(array $cacheable_metadata = [])

Returns an array of regions and their block entities.

Parameters

array $cacheable_metadata

(optional) List of CacheableMetadata objects, keyed by region. This is by reference and is used to pass this information back to the caller.

Return Value

array

The array is first keyed by region machine name, with the values containing an array keyed by block ID, with block entities as the values.