summaryrefslogtreecommitdiffstatshomepage
path: root/core/modules/media_library/src/Routing/RouteSubscriber.php
blob: e0de34edd4dc9092ab1b72814340282b12e0d7f2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php

namespace Drupal\media_library\Routing;

use Drupal\Core\Routing\RouteSubscriberBase;
use Symfony\Component\Routing\RouteCollection;

/**
 * Subscriber for media library routes.
 *
 * @internal
 *   Tagged services are internal.
 */
class RouteSubscriber extends RouteSubscriberBase {

  /**
   * {@inheritdoc}
   */
  protected function alterRoutes(RouteCollection $collection) {
    // Add the media library UI access checks to the widget displays of the
    // media library view.
    if ($route = $collection->get('view.media_library.widget')) {
      $route->addRequirements(['_custom_access' => 'media_library.ui_builder:checkAccess']);
    }
    if ($route = $collection->get('view.media_library.widget_table')) {
      $route->addRequirements(['_custom_access' => 'media_library.ui_builder:checkAccess']);
    }
  }

}