You are here

private function EntityViewModeRestriction::getBlockTypeByUuid in Layout Builder Restrictions 8.2

Helper function to retrieve uuid->type keyed block array.

Return value

str[] A key-value array of uuid-block type.

2 calls to EntityViewModeRestriction::getBlockTypeByUuid()
EntityViewModeRestriction::alterBlockDefinitions in src/Plugin/LayoutBuilderRestriction/EntityViewModeRestriction.php
Alter the block definitions.
EntityViewModeRestriction::blockAllowedinContext in src/Plugin/LayoutBuilderRestriction/EntityViewModeRestriction.php
Determine whether the block being moved is allowed to the destination.

File

src/Plugin/LayoutBuilderRestriction/EntityViewModeRestriction.php, line 312

Class

EntityViewModeRestriction
Controls behavior of the per-view mode plugin.

Namespace

Drupal\layout_builder_restrictions\Plugin\LayoutBuilderRestriction

Code

private function getBlockTypeByUuid() {
  if ($this->moduleHandler
    ->moduleExists('block_content')) {

    // Pre-load all reusable blocks by UUID to retrieve block type.
    $query = $this->database
      ->select('block_content', 'b')
      ->fields('b', [
      'uuid',
      'type',
    ]);
    $results = $query
      ->execute();
    return $results
      ->fetchAllKeyed(0, 1);
  }
  return [];
}