AccountProxyInterface.php 1.4 KB
Newer Older
1
2
3
4
5
6
<?php

namespace Drupal\Core\Session;

/**
 * Defines an interface for a service which has the current account stored.
7
 *
8
9
10
11
12
 * It is generally more useful to use \Drupal\Core\Session\AccountInterface
 * unless one specifically needs the proxying features of this interface.
 *
 * @see \Drupal\Core\Session\AccountInterface
 *
13
 * @ingroup user_api
14
15
16
17
 */
interface AccountProxyInterface extends AccountInterface {

  /**
18
   * Sets the currently wrapped account.
19
20
   *
   * Setting the current account is highly discouraged! Instead, make sure to
21
22
23
24
25
   * 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().
26
   *
27
   * @param \Drupal\Core\Session\AccountInterface $account
28
29
30
31
32
   *   The current account.
   */
  public function setAccount(AccountInterface $account);

  /**
33
   * Gets the currently wrapped account.
34
   *
35
   * @return \Drupal\Core\Session\AccountInterface
36
37
38
39
   *   The current account.
   */
  public function getAccount();

40
41
42
43
44
45
46
47
48
49
  /**
   * 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);
50

51
}