You are here

function lightning_layout_block_alter in Lightning Layout 8.2

Same name and namespace in other branches
  1. 8 lightning_layout.module \lightning_layout_block_alter()

Implements hook_block_alter().

1 call to lightning_layout_block_alter()
HooksTest::testBlockAlter in tests/src/Kernel/HooksTest.php
Tests lightning_layout_block_alter().

File

./lightning_layout.module, line 49
Contains layout functionality for Lightning.

Code

function lightning_layout_block_alter(array &$blocks) {
  $allow = Drupal::config('lightning_layout.settings')
    ->get('entity_blocks');
  if ($allow) {

    // Suppress all entity_block derivatives for entity types that are not
    // explicitly allowed.
    $plugins = preg_grep('/^entity_block:/', array_keys($blocks));
    foreach ($plugins as $plugin_id) {
      if (!in_array(substr($plugin_id, 13), $allow, TRUE)) {
        unset($blocks[$plugin_id]);
      }
    }
  }
}