function media_library_local_tasks_alter

Same name in other branches
  1. 9 core/modules/media_library/media_library.module \media_library_local_tasks_alter()
  2. 8.9.x core/modules/media_library/media_library.module \media_library_local_tasks_alter()
  3. 11.x core/modules/media_library/media_library.module \media_library_local_tasks_alter()

Implements hook_local_tasks_alter().

Removes tasks for the Media library if the view display no longer exists.

File

core/modules/media_library/media_library.module, line 363

Code

function media_library_local_tasks_alter(&$local_tasks) {
    
    /** @var \Symfony\Component\Routing\RouteCollection $route_collection */
    $route_collection = \Drupal::service('router')->getRouteCollection();
    foreach ([
        'media_library.grid',
        'media_library.table',
    ] as $key) {
        if (isset($local_tasks[$key]) && !$route_collection->get($local_tasks[$key]['route_name'])) {
            unset($local_tasks[$key]);
        }
    }
}

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