summaryrefslogtreecommitdiffstats
path: root/Core/SecurityContextInterface.php
diff options
context:
space:
mode:
authorKris Wallsmith <kris.wallsmith@gmail.com>2011-12-08 08:53:01 -0800
committerKris Wallsmith <kris.wallsmith@gmail.com>2011-12-08 08:53:01 -0800
commit571b855fb77836023b28fc3bfd5d5a3b8459e847 (patch)
tree5929eff8b929f7af11bb2f41055f81d25ec10b01 /Core/SecurityContextInterface.php
parent223aaf86a0173c799556c935afa9144d41c76fa2 (diff)
downloadsymfony-security-571b855fb77836023b28fc3bfd5d5a3b8459e847.zip
symfony-security-571b855fb77836023b28fc3bfd5d5a3b8459e847.tar.gz
symfony-security-571b855fb77836023b28fc3bfd5d5a3b8459e847.tar.bz2
[Security] added SecurityContextInterface::getUser()
This changes helps the common use case of fetching the current user and better complies with the Law of Demeter (http://en.wikipedia.org/wiki/Law_of_Demeter). Before (still works): $token = $context->getToken(); $user = $token ? $token->getUser() : null; After: $user = $context->getUser();
Diffstat (limited to 'Core/SecurityContextInterface.php')
-rw-r--r--Core/SecurityContextInterface.php9
1 files changed, 9 insertions, 0 deletions
diff --git a/Core/SecurityContextInterface.php b/Core/SecurityContextInterface.php
index d0c7214..600f7b4 100644
--- a/Core/SecurityContextInterface.php
+++ b/Core/SecurityContextInterface.php
@@ -39,6 +39,15 @@ interface SecurityContextInterface
function setToken(TokenInterface $token = null);
/**
+ * Returns the current user, if one exists.
+ *
+ * @return mixed Returns either an object which implements __toString(),
+ * or a primitive string if there is a token, otherwise
+ * returns null.
+ */
+ function getUser();
+
+ /**
* Checks if the attributes are granted against the current authentication token and optionally supplied object.
*
* @param array $attributes