1<?php
2
3namespace Drupal\Core\Session;
4
5/**
6 * Defines an interface for a service which has the current account stored.
7 *
8 * It is generally more useful to use \Drupal\Core\Session\AccountInterface
9 * unless one specifically needs the proxying features of this interface.
10 *
11 * @see \Drupal\Core\Session\AccountInterface
12 *
13 * @ingroup user_api
14 */
15interface AccountProxyInterface extends AccountInterface {
16
17  /**
18   * Sets the currently wrapped account.
19   *
20   * Setting the current account is highly discouraged! Instead, make sure to
21   * inject the desired user object into the dependent code directly.
22   *
23   * A preferable method of account impersonation is to use
24   * \Drupal\Core\Session\AccountSwitcherInterface::switchTo() and
25   * \Drupal\Core\Session\AccountSwitcherInterface::switchBack().
26   *
27   * @param \Drupal\Core\Session\AccountInterface $account
28   *   The current account.
29   */
30  public function setAccount(AccountInterface $account);
31
32  /**
33   * Gets the currently wrapped account.
34   *
35   * @return \Drupal\Core\Session\AccountInterface
36   *   The current account.
37   */
38  public function getAccount();
39
40  /**
41   * Sets the id of the initial account.
42   *
43   * Never use this method, its sole purpose is to work around weird effects
44   * during mid-request container rebuilds.
45   *
46   * @param int $account_id
47   *   The id of the initial account.
48   */
49  public function setInitialAccountId($account_id);
50
51}
52