class UserConfigContext

Defines a configuration context object for a user account.

This should be used when configuration objects need a context for a user other than the current user.

Hierarchy

Expanded class hierarchy of UserConfigContext

See also

user_mail()

File

drupal/core/modules/user/lib/Drupal/user/UserConfigContext.php, line 22
Contains \Drupal\user\UserConfigContext.

Namespace

Drupal\user
View source
class UserConfigContext extends ConfigContext {

  /**
   * Predefined key for account object.
   */
  const USER_KEY = 'user.account';

  /**
   * Creates the configuration context for user accounts.
   *
   * @param \Drupal\user\UserInterface $account
   *   The account to add to the config context.
   *
   * @return \Drupal\user\UserConfigContext
   *   The user config context object.
   */
  public function setAccount(UserInterface $account) {
    $this
      ->set(self::USER_KEY, $account);

    // Re-initialize since the user change changes the context fundamentally.
    $this
      ->init();
    return $this;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ConfigContext::$data protected property The actual storage of key-value pairs.
ConfigContext::$eventDispatcher protected property An event dispatcher instance to use for configuration events.
ConfigContext::$overrides protected property Any config overrides of key-value pairs.
ConfigContext::$uuid protected property A unique identifier for the context.
ConfigContext::get public function Implements \Drupal\Core\Config\Context\ContextInterface::get(). Overrides ContextInterface::get
ConfigContext::getOverrides public function Implements \Drupal\Core\Config\Context\ContextInterface::getOverrides(). Overrides ContextInterface::getOverrides 1
ConfigContext::getUuid public function Implements \Drupal\Core\Config\Context\ContextInterface::getUuid(). Overrides ContextInterface::getUuid
ConfigContext::init public function Implements \Drupal\Core\Config\Context\ContextInterface::init(). Overrides ContextInterface::init
ConfigContext::notify public function Implements \Drupal\Core\Config\Context\ContextInterface::notify(). Overrides ContextInterface::notify
ConfigContext::set public function Implements \Drupal\Core\Config\Context\ContextInterface::set(). Overrides ContextInterface::set
ConfigContext::setOverrides public function Implements \Drupal\Core\Config\Context\ContextInterface::setOverride(). Overrides ContextInterface::setOverrides 1
ConfigContext::setUuid public function Implements \Drupal\Core\Config\Context\ContextInterface::setUuid(). Overrides ContextInterface::setUuid
ConfigContext::__construct public function Constructs the configuration context.
UserConfigContext::setAccount public function Creates the configuration context for user accounts.
UserConfigContext::USER_KEY constant Predefined key for account object.