function navigation_plugin_filter_block__layout_builder_alter

Same name in other branches
  1. 10 core/modules/navigation/navigation.module \navigation_plugin_filter_block__layout_builder_alter()

Implements hook_plugin_filter_TYPE__CONSUMER_alter().

Curate the blocks available in the Layout Builder "Add Block" UI.

File

core/modules/navigation/navigation.module, line 170

Code

function navigation_plugin_filter_block__layout_builder_alter(array &$definitions, array $extra) {
    if (($extra['section_storage'] ?? NULL) instanceof NavigationSectionStorage) {
        // Remove all blocks other than the ones we support.
        $navigation_safe = [
            'navigation_user',
            'navigation_shortcuts',
            'navigation_menu',
        ];
        $definitions = array_filter($definitions, static function (array $definition, string $plugin_id) use ($navigation_safe) : bool {
            [
                $base_plugin_id,
            ] = explode(PluginBase::DERIVATIVE_SEPARATOR, $plugin_id);
            return in_array($base_plugin_id, $navigation_safe, TRUE);
        }, ARRAY_FILTER_USE_BOTH);
    }
}

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