class RouteSubscriber in Flexiform 8
Same name in this branch
- 8 src/Routing/RouteSubscriber.php \Drupal\flexiform\Routing\RouteSubscriber
- 8 contrib/wizard/src/Routing/RouteSubscriber.php \Drupal\flexiform_wizard\Routing\RouteSubscriber
Subscriber for wizard routes.
Hierarchy
- class \Drupal\Core\Routing\RouteSubscriberBase implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
- class \Drupal\flexiform_wizard\Routing\RouteSubscriber
Expanded class hierarchy of RouteSubscriber
1 string reference to 'RouteSubscriber'
- flexiform_wizard.services.yml in contrib/
wizard/ flexiform_wizard.services.yml - contrib/wizard/flexiform_wizard.services.yml
1 service uses RouteSubscriber
File
- contrib/
wizard/ src/ Routing/ RouteSubscriber.php, line 13
Namespace
Drupal\flexiform_wizard\RoutingView source
class RouteSubscriber extends RouteSubscriberBase {
/**
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* Constructs a RouteSubscriber object.
*
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
*/
public function __construct(EntityTypeManagerInterface $entity_type_manager) {
$this->entityTypeManager = $entity_type_manager;
}
/**
* {@inheritdoc}
*/
public function alterRoutes(RouteCollection $collection) {
foreach ($this->entityTypeManager
->getStorage('flexiform_wizard')
->loadMultiple() as $wizard_id => $wizard) {
$options = [];
foreach ($wizard
->get('parameters') as $param_name => $param_info) {
$options['parameters'][$param_name] = [
'type' => 'entity:' . $param_info['entity_type'],
];
}
$options['parameters']['wizard'] = [
'type' => 'entity:flexiform_wizard',
];
$defaults = [
'_wizard' => '\\Drupal\\flexiform_wizard\\Wizard\\DefaultWizard',
'_title' => 'Wizard',
'wizard' => $wizard_id,
];
$route = new Route($wizard
->get('path'), $defaults, [
'_access' => 'TRUE',
], $options);
$collection
->add("flexiform_wizard.{$wizard_id}", $route);
$route = new Route($wizard
->get('path') . '/{step}', $defaults, [
'_access' => 'TRUE',
], $options);
$collection
->add("flexiform_wizard.{$wizard_id}.step", $route);
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
RouteSubscriber:: |
protected | property | The entity type manager. | |
RouteSubscriber:: |
public | function |
Alters existing routes for a specific collection. Overrides RouteSubscriberBase:: |
|
RouteSubscriber:: |
public | function | Constructs a RouteSubscriber 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 |