You are here

class RouteSubscriber in Batch add terms 8

Class for route alter.

@package Drupal\batch_add_terms\Routing

Hierarchy

  • class \Drupal\Core\Routing\RouteSubscriberBase implements \Symfony\Component\EventDispatcher\EventSubscriberInterface

Expanded class hierarchy of RouteSubscriber

1 string reference to 'RouteSubscriber'
batch_add_terms.services.yml in ./batch_add_terms.services.yml
batch_add_terms.services.yml
1 service uses RouteSubscriber
batch_add_terms.route_subscriber in ./batch_add_terms.services.yml
Drupal\batch_add_terms\Routing\RouteSubscriber

File

src/Routing/RouteSubscriber.php, line 13

Namespace

Drupal\batch_add_terms\Routing
View source
class RouteSubscriber extends RouteSubscriberBase {

  /**
   * {@inheritdoc}
   */
  public function alterRoutes(RouteCollection $collection) {

    // Altering the access permissions as per vppr or taxonomy_access_fix.
    $moduleHandler = \Drupal::service('module_handler');

    // If vppr module enabled.
    if ($moduleHandler
      ->moduleExists('vppr')) {
      if ($route = $collection
        ->get('batch_add_terms.mass_add')) {
        $route
          ->setRequirements([
          '_custom_access' => '\\vppr_route_access',
        ]);
      }
      $route
        ->setOption('op', '');
    }

    // If taxonomy_access_fix module enabled.
    if ($moduleHandler
      ->moduleExists('taxonomy_access_fix')) {
      if ($route = $collection
        ->get('batch_add_terms.mass_add')) {
        $route
          ->setRequirements([
          '_custom_access' => '\\taxonomy_access_fix_route_access',
        ]);
        $route
          ->setOption('op', 'add terms');
      }
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
RouteSubscriber::alterRoutes public function Alters existing routes for a specific collection. Overrides RouteSubscriberBase::alterRoutes
RouteSubscriberBase::getSubscribedEvents public static function Returns an array of event names this subscriber wants to listen to. 5
RouteSubscriberBase::onAlterRoutes public function Delegates the route altering to self::alterRoutes(). 1