You are here

class GroupAdminRouteSubscriber in Group 8

Same name and namespace in other branches
  1. 2.0.x src/Routing/GroupAdminRouteSubscriber.php \Drupal\group\Routing\GroupAdminRouteSubscriber

Sets the _admin_route for specific group-related routes.

Hierarchy

Expanded class hierarchy of GroupAdminRouteSubscriber

1 string reference to 'GroupAdminRouteSubscriber'
group.services.yml in ./group.services.yml
group.services.yml
1 service uses GroupAdminRouteSubscriber
group.admin_path.route_subscriber in ./group.services.yml
Drupal\group\Routing\GroupAdminRouteSubscriber

File

src/Routing/GroupAdminRouteSubscriber.php, line 12

Namespace

Drupal\group\Routing
View source
class GroupAdminRouteSubscriber extends RouteSubscriberBase {

  /**
   * The config factory.
   *
   * @var \Drupal\Core\Config\ConfigFactoryInterface
   */
  protected $configFactory;

  /**
   * Constructs a new GroupAdminRouteSubscriber.
   *
   * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
   *   The config factory.
   */
  public function __construct(ConfigFactoryInterface $config_factory) {
    $this->configFactory = $config_factory;
  }

  /**
   * {@inheritdoc}
   */
  protected function alterRoutes(RouteCollection $collection) {
    if ($this->configFactory
      ->get('group.settings')
      ->get('use_admin_theme')) {
      foreach ($collection
        ->all() as $route) {
        if ($route
          ->hasOption('_group_operation_route')) {
          $route
            ->setOption('_admin_route', TRUE);
        }
      }
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
GroupAdminRouteSubscriber::$configFactory protected property The config factory.
GroupAdminRouteSubscriber::alterRoutes protected function Alters existing routes for a specific collection. Overrides RouteSubscriberBase::alterRoutes
GroupAdminRouteSubscriber::__construct public function Constructs a new GroupAdminRouteSubscriber.
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