class DeprecatedUserRoutesSubscriber
Same name and namespace in other branches
- main core/modules/rest/src/EventSubscriber/DeprecatedUserRoutesSubscriber.php \Drupal\rest\EventSubscriber\DeprecatedUserRoutesSubscriber
Replace the deprecated user module routes with our own.
Hierarchy
- class \Drupal\rest\EventSubscriber\DeprecatedUserRoutesSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
Expanded class hierarchy of DeprecatedUserRoutesSubscriber
File
-
core/
modules/ rest/ src/ EventSubscriber/ DeprecatedUserRoutesSubscriber.php, line 12
Namespace
Drupal\rest\EventSubscriberView source
class DeprecatedUserRoutesSubscriber implements EventSubscriberInterface {
/**
* Replace the deprecated controllers on user.module's routes with ours.
*
* @param \Drupal\Core\Routing\RouteBuildEvent $event
* The route build event.
*/
public function onRouteAlter(RouteBuildEvent $event) : void {
foreach ([
'pass',
'login',
'login_status',
'logout',
] as $route_name) {
$user_route = $event->getRouteCollection()
->get("user.{$route_name}.http");
$rest_route = $event->getRouteCollection()
->get("rest.{$route_name}");
if ($user_route && $rest_route) {
$user_route->setDefault('_controller', $rest_route->getDefault('_controller'));
}
}
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() : array {
$events[RoutingEvents::ALTER] = 'onRouteAlter';
return $events;
}
}
Members
| Title Sort descending | Modifiers | Object type | Summary |
|---|---|---|---|
| DeprecatedUserRoutesSubscriber::getSubscribedEvents | public static | function | |
| DeprecatedUserRoutesSubscriber::onRouteAlter | public | function | Replace the deprecated controllers on user.module's routes with ours. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.