You are here

class Fz152RouteSubscriber in FZ152 8

Listens to the dynamic trousers route events.

Hierarchy

Expanded class hierarchy of Fz152RouteSubscriber

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

File

src/Routing/Fz152RouteSubscriber.php, line 12

Namespace

Drupal\fz152\Routing
View source
class Fz152RouteSubscriber extends RouteSubscriberBase {

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

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

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

    // Try to get the route from the current collection.
    $name = 'fz152.privacy_policy_page';
    if ($route = $collection
      ->get($name)) {
      $config = $this->configFactory
        ->get($name);
      if ($config
        ->get('enable')) {
        $route
          ->setPath($config
          ->get('path'));
      }
      else {
        $collection
          ->remove($name);
      }
    }
  }

}

Members

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