You are here

private function BlocksDataCollector::getBlocksData in Devel 4.x

Same name and namespace in other branches
  1. 8.3 webprofiler/src/DataCollector/BlocksDataCollector.php \Drupal\webprofiler\DataCollector\BlocksDataCollector::getBlocksData()
  2. 8 webprofiler/src/DataCollector/BlocksDataCollector.php \Drupal\webprofiler\DataCollector\BlocksDataCollector::getBlocksData()
  3. 8.2 webprofiler/src/DataCollector/BlocksDataCollector.php \Drupal\webprofiler\DataCollector\BlocksDataCollector::getBlocksData()

Parameters

$decorator:

$storage:

Return value

array

1 call to BlocksDataCollector::getBlocksData()
BlocksDataCollector::collect in webprofiler/src/DataCollector/BlocksDataCollector.php

File

webprofiler/src/DataCollector/BlocksDataCollector.php, line 118

Class

BlocksDataCollector
Class BlocksDataCollector.

Namespace

Drupal\webprofiler\DataCollector

Code

private function getBlocksData(EntityDecorator $decorator, EntityStorageInterface $storage) {
  $blocks = [];

  /** @var \Drupal\block\BlockInterface $block */
  foreach ($decorator
    ->getEntities() as $block) {

    /** @var \Drupal\block\Entity\Block $entity */
    if (NULL !== $block && ($entity = $storage
      ->load($block
      ->get('id')))) {
      $route = '';
      if ($entity
        ->hasLinkTemplate('edit-form')) {
        $route = $entity
          ->toUrl('edit-form')
          ->toString();
      }
      $id = $block
        ->get('id');
      $blocks[$id] = [
        'id' => $id,
        'region' => $block
          ->getRegion(),
        'status' => $block
          ->get('status'),
        'theme' => $block
          ->getTheme(),
        'plugin' => $block
          ->get('plugin'),
        'settings' => $block
          ->get('settings'),
        'route' => $route,
      ];
    }
  }
  return $blocks;
}