You are here

function thunder_article_menu_local_tasks_alter in Thunder 8.2

Same name and namespace in other branches
  1. 8.3 modules/thunder_article/thunder_article.module \thunder_article_menu_local_tasks_alter()
  2. 8.4 modules/thunder_article/thunder_article.module \thunder_article_menu_local_tasks_alter()
  3. 6.0.x modules/thunder_article/thunder_article.module \thunder_article_menu_local_tasks_alter()
  4. 6.1.x modules/thunder_article/thunder_article.module \thunder_article_menu_local_tasks_alter()

Implements hook_menu_local_tasks_alter().

File

modules/thunder_article/thunder_article.module, line 15
Thunder Article module hooks.

Code

function thunder_article_menu_local_tasks_alter(&$data, $route_name) {
  foreach ($data['tabs'] as $key => $tab) {
    foreach ($tab as $task => $link) {
      if (in_array($task, [
        'views_view:view.scheduler_scheduled_content.overview',
        'thunder_article.content_view:thunder_article.scheduler',
      ], TRUE)) {

        // Access configuration inside the loop so that we don't do unnecessary
        // queries.
        $config = \Drupal::service('config.factory')
          ->get('thunder_article.settings');
        $link_ref =& $data['tabs'][$key][$task];
        $link_ref['#access'] = ($task === 'views_view:view.scheduler_scheduled_content.overview' xor $config
          ->get('move_scheduler_local_task'));
        $link_ref['#cache']['tags'] = Cache::mergeTags(isset($link_ref['#cache']['tags']) ? $link_ref['#cache']['tags'] : [], $config
          ->getCacheTags());
      }
    }
  }
}