class CasRouteEnhancer in CAS 2.x
Same name and namespace in other branches
- 8 src/Routing/CasRouteEnhancer.php \Drupal\cas\Routing\CasRouteEnhancer
Class CasRouteEnhancer.
Override the default logout controller action with our own.
Our controller action will log the user out of Drupal and then redirect to the CAS server logout page as well.
Hierarchy
- class \Drupal\cas\Routing\CasRouteEnhancer implements EnhancerInterface
Expanded class hierarchy of CasRouteEnhancer
1 file declares its use of CasRouteEnhancer
- CasRouteEnhancerTest.php in tests/
src/ Unit/ Routing/ CasRouteEnhancerTest.php
1 string reference to 'CasRouteEnhancer'
1 service uses CasRouteEnhancer
File
- src/
Routing/ CasRouteEnhancer.php, line 18
Namespace
Drupal\cas\RoutingView source
class CasRouteEnhancer implements EnhancerInterface {
/**
* Stores settings object.
*
* @var \Drupal\Core\Config\Config
*/
protected $settings;
/**
* Constructor.
*
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* The config factory.
*/
public function __construct(ConfigFactoryInterface $config_factory) {
$this->settings = $config_factory
->get('cas.settings');
}
/**
* {@inheritdoc}
*/
public function enhance(array $defaults, Request $request) {
$route = $defaults[RouteObjectInterface::ROUTE_OBJECT];
if ($route
->getPath() == '/user/logout') {
// Replace the logout controller with our own if the logged in user logged
// in using CAS and if we're configured to perform a CAS server logout
// during normal Drupal logouts. Overriding the controller allows us to
// redirect the user to the CAS server logout after logging out locally.
if ($this->settings
->get('logout.cas_logout') && $request
->getSession() && $request
->getSession()
->get('is_cas_user')) {
$defaults['_controller'] = '\\Drupal\\cas\\Controller\\LogoutController::logout';
}
}
return $defaults;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CasRouteEnhancer:: |
protected | property | Stores settings object. | |
CasRouteEnhancer:: |
public | function |
Updates the defaults for a route definition based on the request. Overrides EnhancerInterface:: |
|
CasRouteEnhancer:: |
public | function | Constructor. |