You are here

class SupportTicketAdminRouteSubscriber in Support Ticketing System 8

Sets the _admin_route for specific support ticket-related routes.

Hierarchy

Expanded class hierarchy of SupportTicketAdminRouteSubscriber

1 string reference to 'SupportTicketAdminRouteSubscriber'
support_ticket.services.yml in modules/support_ticket/support_ticket.services.yml
modules/support_ticket/support_ticket.services.yml
1 service uses SupportTicketAdminRouteSubscriber
support_ticket.admin_path.route_subscriber in modules/support_ticket/support_ticket.services.yml
Drupal\support_ticket\EventSubscriber\SupportTicketAdminRouteSubscriber

File

modules/support_ticket/src/EventSubscriber/SupportTicketAdminRouteSubscriber.php, line 17
Contains \Drupal\support_ticket\EventSubscriber\SupportTicketAdminRouteSubscriber.

Namespace

Drupal\support_ticket\EventSubscriber
View source
class SupportTicketAdminRouteSubscriber extends RouteSubscriberBase {

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

  /**
   * Constructs a new SupportTicketAdminRouteSubscriber.
   *
   * @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('support_ticket.settings')
      ->get('use_admin_theme')) {
      foreach ($collection
        ->all() as $route) {
        if ($route
          ->hasOption('_support_ticket_operation_route')) {
          $route
            ->setOption('_admin_route', TRUE);
        }
      }
    }
  }

}

Members

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