diff core/lib/Drupal/Core/Session/AccountProxyInterface.php @ 0:4c8ae668cc8c

Initial import (non-working)
author Chris Cannam
date Wed, 29 Nov 2017 16:09:58 +0000
parents
children 1fec387a4317
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/lib/Drupal/Core/Session/AccountProxyInterface.php	Wed Nov 29 16:09:58 2017 +0000
@@ -0,0 +1,46 @@
+<?php
+
+namespace Drupal\Core\Session;
+
+/**
+ * Defines an interface for a service which has the current account stored.
+ *
+ * @ingroup user_api
+ */
+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);
+
+}