You are here

interface AccountProxyInterface in Drupal 10

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Session/AccountProxyInterface.php \Drupal\Core\Session\AccountProxyInterface
  2. 9 core/lib/Drupal/Core/Session/AccountProxyInterface.php \Drupal\Core\Session\AccountProxyInterface

Defines an interface for a service which has the current account stored.

It is generally more useful to use \Drupal\Core\Session\AccountInterface unless one specifically needs the proxying features of this interface.

Hierarchy

Expanded class hierarchy of AccountProxyInterface

All classes that implement AccountProxyInterface

See also

\Drupal\Core\Session\AccountInterface

Related topics

11 files declare their use of AccountProxyInterface
AuthenticationSubscriber.php in core/lib/Drupal/Core/EventSubscriber/AuthenticationSubscriber.php
FormBuilderTest.php in core/tests/Drupal/Tests/Core/Form/FormBuilderTest.php
Contains \Drupal\Tests\Core\Form\FormBuilderTest.
LinkAccessConstraintValidator.php in core/modules/link/src/Plugin/Validation/Constraint/LinkAccessConstraintValidator.php
PrivateTempStore.php in core/lib/Drupal/Core/TempStore/PrivateTempStore.php
PrivateTempStoreFactory.php in core/lib/Drupal/Core/TempStore/PrivateTempStoreFactory.php

... See full list

File

core/lib/Drupal/Core/Session/AccountProxyInterface.php, line 15

Namespace

Drupal\Core\Session
View source
interface AccountProxyInterface extends AccountInterface {

  /**
   * Sets the currently wrapped account.
   *
   * Setting the current account is highly discouraged! Instead, make sure to
   * inject the desired user object into the dependent code directly.
   *
   * A preferable method of account impersonation is to use
   * \Drupal\Core\Session\AccountSwitcherInterface::switchTo() and
   * \Drupal\Core\Session\AccountSwitcherInterface::switchBack().
   *
   * @param \Drupal\Core\Session\AccountInterface $account
   *   The current account.
   */
  public function setAccount(AccountInterface $account);

  /**
   * Gets the currently wrapped account.
   *
   * @return \Drupal\Core\Session\AccountInterface
   *   The current account.
   */
  public function getAccount();

  /**
   * Sets the id of the initial account.
   *
   * Never use this method, its sole purpose is to work around weird effects
   * during mid-request container rebuilds.
   *
   * @param int $account_id
   *   The id of the initial account.
   */
  public function setInitialAccountId($account_id);

}

Members