You are here

private function BlocksDataCollector::getBlocksData in Devel 8.2

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. 4.x 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
Collects data for the given Request and Response.

File

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

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 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;
}