class Fz152RouteSubscriber in FZ152 8
Listens to the dynamic trousers route events.
Hierarchy
- class \Drupal\Core\Routing\RouteSubscriberBase implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
- class \Drupal\fz152\Routing\Fz152RouteSubscriber
Expanded class hierarchy of Fz152RouteSubscriber
1 string reference to 'Fz152RouteSubscriber'
1 service uses Fz152RouteSubscriber
File
- src/
Routing/ Fz152RouteSubscriber.php, line 12
Namespace
Drupal\fz152\RoutingView 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
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Fz152RouteSubscriber:: |
protected | property | The config factory. | |
Fz152RouteSubscriber:: |
protected | function |
Alters existing routes for a specific collection. Overrides RouteSubscriberBase:: |
|
Fz152RouteSubscriber:: |
public | function | Constructs a Fz152RouteSubscriber object. | |
RouteSubscriberBase:: |
public static | function | Returns an array of event names this subscriber wants to listen to. | 5 |
RouteSubscriberBase:: |
public | function | Delegates the route altering to self::alterRoutes(). | 1 |