class CasAutoAssignRolesSubscriber in CAS 8
Same name and namespace in other branches
- 2.x src/Subscriber/CasAutoAssignRolesSubscriber.php \Drupal\cas\Subscriber\CasAutoAssignRolesSubscriber
Provides a CasAutoAssignRoleSubscriber.
Hierarchy
- class \Drupal\cas\Subscriber\CasAutoAssignRolesSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
Expanded class hierarchy of CasAutoAssignRolesSubscriber
1 string reference to 'CasAutoAssignRolesSubscriber'
1 service uses CasAutoAssignRolesSubscriber
File
- src/
Subscriber/ CasAutoAssignRolesSubscriber.php, line 13
Namespace
Drupal\cas\SubscriberView source
class CasAutoAssignRolesSubscriber implements EventSubscriberInterface {
/**
* Stores settings object.
*
* @var \Drupal\Core\Config\ConfigFactoryInterface
*/
protected $settings;
/**
* CasAutoAssignRoleSubscriber constructor.
*
* @param \Drupal\Core\Config\ConfigFactoryInterface $config
* A config factory instance.
*/
public function __construct(ConfigFactoryInterface $config) {
$this->settings = $config
->get('cas.settings');
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
$events[CasHelper::EVENT_PRE_REGISTER][] = [
'assignRolesOnRegistration',
];
return $events;
}
/**
* The entry point for our subscriber.
*
* Assign roles to a user that just registered via CAS.
*
* @param \Drupal\cas\Event\CasPreRegisterEvent $event
* The event object.
*/
public function assignRolesOnRegistration(CasPreRegisterEvent $event) {
$auto_assigned_roles = $this->settings
->get('user_accounts.auto_assigned_roles');
if (!empty($auto_assigned_roles)) {
$event
->setPropertyValue('roles', $auto_assigned_roles);
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CasAutoAssignRolesSubscriber:: |
protected | property | Stores settings object. | |
CasAutoAssignRolesSubscriber:: |
public | function | The entry point for our subscriber. | |
CasAutoAssignRolesSubscriber:: |
public static | function | Returns an array of event names this subscriber wants to listen to. | |
CasAutoAssignRolesSubscriber:: |
public | function | CasAutoAssignRoleSubscriber constructor. |