class CasUserInteractionTestSubscriber in CAS 2.x
Same name and namespace in other branches
- 8 tests/modules/cas_user_interaction_test/src/CasUserInteractionTestSubscriber.php \Drupal\cas_user_interaction_test\CasUserInteractionTestSubscriber
Class CasTestSubscriber.
Hierarchy
- class \Drupal\cas_user_interaction_test\CasUserInteractionTestSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
Expanded class hierarchy of CasUserInteractionTestSubscriber
1 string reference to 'CasUserInteractionTestSubscriber'
- cas_user_interaction_test.services.yml in tests/
modules/ cas_user_interaction_test/ cas_user_interaction_test.services.yml - tests/modules/cas_user_interaction_test/cas_user_interaction_test.services.yml
1 service uses CasUserInteractionTestSubscriber
- cas_user_interaction_test.subscriber in tests/
modules/ cas_user_interaction_test/ cas_user_interaction_test.services.yml - Drupal\cas_user_interaction_test\CasUserInteractionTestSubscriber
File
- tests/
modules/ cas_user_interaction_test/ src/ CasUserInteractionTestSubscriber.php, line 14
Namespace
Drupal\cas_user_interaction_testView source
class CasUserInteractionTestSubscriber implements EventSubscriberInterface {
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
return [
CasHelper::EVENT_PRE_USER_LOAD_REDIRECT => 'onPreUserLoadRedirect',
];
}
/**
* Redirects to a form that asks user to accept the site's 'Legal Notice'.
*
* @param \Drupal\cas\Event\CasPreUserLoadRedirectEvent $event
* The event.
*/
public function onPreUserLoadRedirect(CasPreUserLoadRedirectEvent $event) {
$is_legal_notice_changed = \Drupal::state()
->get('cas_user_interaction_test.changed', FALSE);
$local_account = \Drupal::service('externalauth.externalauth')
->load($event
->getPropertyBag()
->getUsername(), 'cas');
// Add a redirect only if a local account exists (i.e. it's a login
// operation) and the site's 'Legal Notice' has changed.
if ($local_account && $is_legal_notice_changed) {
/** @var \Drupal\Core\TempStore\PrivateTempStore $tempstore */
$tempstore = \Drupal::service('tempstore.private')
->get('cas_user_interaction_test');
$tempstore
->set('ticket', $event
->getTicket());
$tempstore
->set('property_bag', $event
->getPropertyBag());
$event
->setRedirectResponse(new RedirectResponse(Url::fromRoute('cas_user_interaction_test.form')
->toString()));
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CasUserInteractionTestSubscriber:: |
public static | function | ||
CasUserInteractionTestSubscriber:: |
public | function | Redirects to a form that asks user to accept the site's 'Legal Notice'. |