class SamlauthUserSyncEvent in SAML Authentication 8.2
Same name and namespace in other branches
- 8.3 src/Event/SamlauthUserSyncEvent.php \Drupal\samlauth\Event\SamlauthUserSyncEvent
- 4.x src/Event/SamlauthUserSyncEvent.php \Drupal\samlauth\Event\SamlauthUserSyncEvent
Wraps a samlauth user sync event for event listeners.
Hierarchy
- class \Drupal\samlauth\Event\SamlauthUserSyncEvent extends \Symfony\Component\EventDispatcher\Event
Expanded class hierarchy of SamlauthUserSyncEvent
2 files declare their use of SamlauthUserSyncEvent
- SamlService.php in src/
SamlService.php - UserSyncEventSubscriber.php in src/
EventSubscriber/ UserSyncEventSubscriber.php
File
- src/
Event/ SamlauthUserSyncEvent.php, line 11
Namespace
Drupal\samlauth\EventView source
class SamlauthUserSyncEvent extends Event {
/**
* The Drupal user account.
*
* @var \Drupal\user\UserInterface
*/
protected $account;
/**
* The SAML attributes received from the IDP.
*
* Single values are typically represented as one-element arrays.
*
* @var array
*/
protected $attributes;
/**
* A flag indicating that the account was changed.
*
* @var bool
*/
protected $accountChanged;
/**
* Constructs a samlauth user sync event object.
*
* @param \Drupal\user\UserInterface $account
* The Drupal user account.
* @param array $attributes
* The SAML attributes received from the IDP.
*/
public function __construct(UserInterface $account, array $attributes) {
$this->account = $account;
$this->attributes = $attributes;
}
/**
* Gets the Drupal user entity.
*
* @return \Drupal\user\UserInterface $account
* The Drupal user account.
*/
public function getAccount() {
return $this->account;
}
/**
* Sets the altered Drupal user entity.
*
* @param \Drupal\user\UserInterface $account
* The Drupal user account.
*/
public function setAccount(UserInterface $account) {
$this->account = $account;
}
/**
* Gets the SAML attributes.
*
* @return array
* The SAML attributes received from the IDP.
*/
public function getAttributes() {
return $this->attributes;
}
/**
* Sets the SAML attributes.
*
* Event handlers typically will use only the getter, to inspect attributes
* that are present in the SAML message. This setter provides a way to
* override those values in edge cases but is not meant to be used often. It
* provides no nice DX; the caller needs to make sure that all attributes are
* set at once (probably by first using getAttributes() and changing the
* appropriate values). The caller also needs to make sure that values are
* structured as other event subscribers expect them (which is likely to be
* single-value arrays).
*
* @param array $attributes
* An array containing SAML attributes.
*/
public function setAttributes(array $attributes) {
$this->attributes = $attributes;
}
/**
* Marks the user account as changed.
*
* This is the way for event subscribers to make sure user account gets saved.
* This method exists because subscribers must never save new accounts by
* themselves. (Non-new accounts could be saved by the event subscribers but
* just calling markAccountChanged() will keep the account from being saved
* multiple times by multiple subscribers.)
*/
public function markAccountChanged() {
$this->accountChanged = TRUE;
}
/**
* Checks whether the user account was marked as changed.
*
* This is typically done afterwards by the code that dispatches this.
*
* @return bool
* TRUE if the user account was marked as changed.
*/
public function isAccountChanged() {
return $this->accountChanged;
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
SamlauthUserSyncEvent:: |
protected | property | The Drupal user account. | |
SamlauthUserSyncEvent:: |
protected | property | A flag indicating that the account was changed. | |
SamlauthUserSyncEvent:: |
protected | property | The SAML attributes received from the IDP. | |
SamlauthUserSyncEvent:: |
public | function | Gets the Drupal user entity. | |
SamlauthUserSyncEvent:: |
public | function | Gets the SAML attributes. | |
SamlauthUserSyncEvent:: |
public | function | Checks whether the user account was marked as changed. | |
SamlauthUserSyncEvent:: |
public | function | Marks the user account as changed. | |
SamlauthUserSyncEvent:: |
public | function | Sets the altered Drupal user entity. | |
SamlauthUserSyncEvent:: |
public | function | Sets the SAML attributes. | |
SamlauthUserSyncEvent:: |
public | function | Constructs a samlauth user sync event object. |