public function BlockRenderController::viewMultiple

Implements Drupal\Core\Entity\EntityRenderControllerInterface::viewMultiple().

Overrides EntityRenderControllerInterface::viewMultiple

1 call to BlockRenderController::viewMultiple()

File

drupal/core/modules/block/lib/Drupal/block/BlockRenderController.php, line 36
Contains \Drupal\block\BlockRenderController.

Class

BlockRenderController
Provides a Block render controller.

Namespace

Drupal\block

Code

public function viewMultiple(array $entities = array(), $view_mode = 'full', $langcode = NULL) {
  $build = array();
  foreach ($entities as $entity_id => $entity) {
    $plugin = $entity
      ->getPlugin();
    $plugin_id = $plugin
      ->getPluginId();
    if ($content = $plugin
      ->build()) {
      $configuration = $plugin
        ->getConfig();
      $build[$entity_id] = array(
        '#theme' => 'block',
        'content' => $content,
        '#configuration' => $configuration,
        '#plugin_id' => $plugin_id,
      );
      $build[$entity_id]['#configuration']['label'] = check_plain($configuration['label']);
    }
    else {
      $build[$entity_id] = array();
    }
    list($base_id) = explode(':', $plugin_id);
    drupal_alter(array(
      'block_view',
      "block_view_{$base_id}",
    ), $build[$entity_id], $plugin);

    // @todo Remove after fixing http://drupal.org/node/1989568.
    $build[$entity_id]['#block'] = $entity;
  }
  return $build;
}