| Server IP : 195.130.67.5 / Your IP : 216.73.217.154 Web Server : Microsoft-IIS/10.0 System : Windows NT WEBSERVER1 10.0 build 17763 (Windows Server 2016) i586 User : IUSR ( 0) PHP Version : 7.4.19 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /Old Sites/enoikio/modules/cas/src/Routing/ |
Upload File : |
<?php
namespace Drupal\cas\Routing;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Routing\EnhancerInterface;
use Symfony\Cmf\Component\Routing\RouteObjectInterface;
use Symfony\Component\HttpFoundation\Request;
/**
* 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.
*/
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;
}
}