function seven_preprocess_block_content_add_list

Same name and namespace in other branches
  1. 8.9.x core/themes/seven/seven.theme \seven_preprocess_block_content_add_list()

Implements hook_preprocess_HOOK() for block content add list templates.

Displays the list of available custom block types for creation, adding separate variables for the label and url.

File

core/themes/seven/seven.theme, line 79

Code

function seven_preprocess_block_content_add_list(&$variables) {
    if (!empty($variables['content'])) {
        foreach ($variables['content'] as $type) {
            $variables['types'][$type->id()]['label'] = $type->label();
            $options = [
                'query' => \Drupal::request()->query
                    ->all(),
            ];
            $variables['types'][$type->id()]['url'] = Url::fromRoute('block_content.add_form', [
                'block_content_type' => $type->id(),
            ], $options)
                ->toString();
        }
    }
}

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