You are here

micon_local_task.module in Micon 8

Same filename and directory in other branches
  1. 2.x micon_local_task/micon_local_task.module

File

micon_local_task/micon_local_task.module
View source
<?php

/**
 * @file
 * Contains micon_local_task.module.
 */
use Drupal\Core\Routing\RouteMatchInterface;

/**
 * Implements hook_help().
 */
function micon_local_task_help($route_name, RouteMatchInterface $route_match) {
  switch ($route_name) {

    // Main module help for the micon_local_task module.
    case 'help.page.micon_local_task':
      $output = '';
      $output .= '<h3>' . t('About') . '</h3>';
      $output .= '<p>' . t('The Micon local task module provides automatic icon placement within the local task tab items.') . '</p>';
      return $output;
    default:
  }
}

/**
 * Implements hook_menu_local_tasks_alter().
 */
function micon_local_task_menu_local_tasks_alter(&$data, $route_name) {
  if (!empty($data['tabs'])) {
    $config = \Drupal::config('micon_local_task.config');
    foreach ($data['tabs'] as &$group) {
      foreach ($group as &$tab) {
        $title = $tab['#link']['title'];
        $tab['#link']['title'] = micon($title)
          ->addMatchPrefix('local_task')
          ->setIconOnly($config
          ->get('icon_only'));
      }
    }
  }
}