You are here

function block_blacklist_plugin_filter_block__layout_builder_alter in Block Blacklist [Deprecated] 8

Implements hook_plugin_filter_TYPE__CONSUMER_alter().

File

./block_blacklist.module, line 32
Contains block_blacklist.module.

Code

function block_blacklist_plugin_filter_block__layout_builder_alter(&$definitions) {
  $blacklistService = \Drupal::service('block_blacklist.blacklist');
  $settings = \Drupal::config('block_blacklist.settings');
  $options = [
    'match' => !empty($settings) ? trim($settings
      ->get('layout_match')) : '',
    'prefix' => !empty($settings) ? trim($settings
      ->get('layout_prefix')) : '',
    'regex' => !empty($settings) ? trim($settings
      ->get('layout_regex')) : '',
  ];
  $blacklistService
    ->setUp($options);
  if (!$blacklistService
    ->hasSettings()) {
    return;
  }
  $callback = [
    $blacklistService,
    'blockIsAllowed',
  ];
  $definitions = array_filter($definitions, $callback, ARRAY_FILTER_USE_KEY);
}