You are here

function block_list_override_plugin_filter_block__layout_builder_alter in Block List Override 1.0.x

File

./block_list_override.module, line 33
Contains block_list_override.module.

Code

function block_list_override_plugin_filter_block__layout_builder_alter(&$definitions) {
  $listService = \Drupal::service('block_list_override.list');
  $settings = \Drupal::config('block_list_override.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')) : '',
    'negate' => !empty($settings) ? $settings
      ->get('layout_negate') : FALSE,
  ];
  $listService
    ->setUp($options);
  if (!$listService
    ->hasSettings()) {
    return;
  }
  $callback = [
    $listService,
    'blockIsAllowed',
  ];
  $definitions = array_filter($definitions, $callback, ARRAY_FILTER_USE_KEY);
}