function layout_builder_plugin_filter_block__block_ui_alter

Same name in other branches
  1. 9 core/modules/layout_builder/layout_builder.module \layout_builder_plugin_filter_block__block_ui_alter()
  2. 8.9.x core/modules/layout_builder/layout_builder.module \layout_builder_plugin_filter_block__block_ui_alter()
  3. 11.x core/modules/layout_builder/layout_builder.module \layout_builder_plugin_filter_block__block_ui_alter()

Implements hook_plugin_filter_TYPE__CONSUMER_alter().

File

core/modules/layout_builder/layout_builder.module, line 278

Code

function layout_builder_plugin_filter_block__block_ui_alter(array &$definitions, array $extra) {
    foreach ($definitions as $id => $definition) {
        // Filter out any layout_builder-provided block that has required context
        // definitions.
        if ($definition['provider'] === 'layout_builder' && !empty($definition['context_definitions'])) {
            
            /** @var \Drupal\Core\Plugin\Context\ContextDefinitionInterface $context_definition */
            foreach ($definition['context_definitions'] as $context_definition) {
                if ($context_definition->isRequired()) {
                    unset($definitions[$id]);
                    break;
                }
            }
        }
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.