You are here

function block_blacklist_block_alter in Block Blacklist [Deprecated] 8

Implements hook_block_alter().

File

./block_blacklist.module, line 11
Contains block_blacklist.module.

Code

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