You are here

function openlayers_ui_menu_local_tasks_alter in Openlayers 7.3

Implements hook_menu_local_tasks_alter().

File

modules/openlayers_ui/openlayers_ui.module, line 107
Administrative UI for openlayers.

Code

function openlayers_ui_menu_local_tasks_alter(&$data, $router_item, $root_path) {
  $path = 'admin/structure/openlayers';
  if (substr($root_path, 0, 26) == $path) {
    $path_exploded = explode('/', $root_path);
    foreach (\Drupal\openlayers\Openlayers::getPluginTypes() as $plugin_type) {
      if (count($path_exploded) >= 4) {
        if ($path_exploded[3] == $plugin_type . 's') {
          continue;
        }
      }
      $data['actions']['output'][] = array(
        '#theme' => 'menu_local_action',
        '#link' => array(
          'path' => $path . '/' . $plugin_type . 's/add',
          'title' => t('Add new @plugin_type', array(
            '@plugin_type' => $plugin_type,
          )),
          'href' => $path . '/' . $plugin_type . 's/add',
        ),
      );
    }
  }
}