class ParamConverterSubscriber
Same name in other branches
- 9 core/lib/Drupal/Core/EventSubscriber/ParamConverterSubscriber.php \Drupal\Core\EventSubscriber\ParamConverterSubscriber
- 8.9.x core/lib/Drupal/Core/EventSubscriber/ParamConverterSubscriber.php \Drupal\Core\EventSubscriber\ParamConverterSubscriber
- 10 core/lib/Drupal/Core/EventSubscriber/ParamConverterSubscriber.php \Drupal\Core\EventSubscriber\ParamConverterSubscriber
Event subscriber for registering parameter converters with routes.
Hierarchy
- class \Drupal\Core\EventSubscriber\ParamConverterSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
Expanded class hierarchy of ParamConverterSubscriber
File
-
core/
lib/ Drupal/ Core/ EventSubscriber/ ParamConverterSubscriber.php, line 13
Namespace
Drupal\Core\EventSubscriberView source
class ParamConverterSubscriber implements EventSubscriberInterface {
/**
* The parameter converter manager.
*
* @var \Drupal\Core\ParamConverter\ParamConverterManagerInterface
*/
protected $paramConverterManager;
/**
* Constructs a new ParamConverterSubscriber.
*
* @param \Drupal\Core\ParamConverter\ParamConverterManagerInterface $param_converter_manager
* The parameter converter manager that will be responsible for upcasting
* request attributes.
*/
public function __construct(ParamConverterManagerInterface $param_converter_manager) {
$this->paramConverterManager = $param_converter_manager;
}
/**
* Applies parameter converters to route parameters.
*
* @param \Drupal\Core\Routing\RouteBuildEvent $event
* The event to process.
*/
public function onRoutingRouteAlterSetParameterConverters(RouteBuildEvent $event) {
$this->paramConverterManager
->setRouteParameterConverters($event->getRouteCollection());
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() : array {
// Run after \Drupal\system\EventSubscriber\AdminRouteSubscriber.
$events[RoutingEvents::ALTER][] = [
'onRoutingRouteAlterSetParameterConverters',
-220,
];
return $events;
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
ParamConverterSubscriber::$paramConverterManager | protected | property | The parameter converter manager. |
ParamConverterSubscriber::getSubscribedEvents | public static | function | |
ParamConverterSubscriber::onRoutingRouteAlterSetParameterConverters | public | function | Applies parameter converters to route parameters. |
ParamConverterSubscriber::__construct | public | function | Constructs a new ParamConverterSubscriber. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.