You are here

function seeds_toolbar_preprocess_seeds_add in Seeds Toolbar 8

Implements hook_preprocess_hook().

File

./seeds_toolbar.module, line 295
Contains seeds_toolbar.module.

Code

function seeds_toolbar_preprocess_seeds_add(&$variables) {

  // TODO: Find a more dynamic way to build menus.
  $seeds_manager = \Drupal::service('seeds_toolbar.manager');
  $variables['content_links'] = $seeds_manager
    ->buildMenu('node_type', 'node.add');
  $variables['content_collection'] = [
    '#type' => 'link',
    '#title' => t('Content'),
    '#url' => Url::fromRoute('system.admin_content'),
  ];
  $variables['taxonomy_links'] = $seeds_manager
    ->buildMenu('taxonomy_vocabulary', 'entity.taxonomy_term.add_form');
  $variables['taxonomy_collection'] = [
    '#type' => 'link',
    '#title' => t('Taxonomies'),
    '#url' => Url::fromRoute('entity.taxonomy_vocabulary.collection'),
  ];
  $variables['media_links'] = $seeds_manager
    ->buildMenu('media_type', 'entity.media.add_form');
  $variables['media_collection'] = [
    '#type' => 'link',
    '#title' => t('Media'),
    '#url' => Url::fromRoute('entity.media.collection'),
  ];
  $variables['block_links'] = $seeds_manager
    ->buildMenu('block_content_type', 'block_content.add_form');
  $variables['block_collection'] = [
    '#type' => 'link',
    '#title' => t('Blocks'),
    '#url' => Url::fromRoute('entity.block_content.collection'),
  ];
}