summaryrefslogtreecommitdiffstats
path: root/Core/Authentication/Token
diff options
context:
space:
mode:
authorJohannes Schmitt <schmittjoh@gmail.com>2011-03-12 09:26:37 +0100
committerFabien Potencier <fabien.potencier@gmail.com>2011-03-12 13:24:57 +0100
commit5a06947e48c33dc57e21e4316c8b7c6e8f5827b0 (patch)
tree8d8baf38e6f19de42603920733e60ad4b9a755d6 /Core/Authentication/Token
parent4b44ea84455acab6195fc3d17ae82212d4d56b04 (diff)
downloadsymfony-security-5a06947e48c33dc57e21e4316c8b7c6e8f5827b0.zip
symfony-security-5a06947e48c33dc57e21e4316c8b7c6e8f5827b0.tar.gz
symfony-security-5a06947e48c33dc57e21e4316c8b7c6e8f5827b0.tar.bz2
re-added a __toString method for debugging purposes
Diffstat (limited to 'Core/Authentication/Token')
-rw-r--r--Core/Authentication/Token/AbstractToken.php16
-rw-r--r--Core/Authentication/Token/TokenInterface.php9
2 files changed, 25 insertions, 0 deletions
diff --git a/Core/Authentication/Token/AbstractToken.php b/Core/Authentication/Token/AbstractToken.php
index 210e46d..ee6b207 100644
--- a/Core/Authentication/Token/AbstractToken.php
+++ b/Core/Authentication/Token/AbstractToken.php
@@ -204,4 +204,20 @@ abstract class AbstractToken implements TokenInterface
{
$this->attributes[$name] = $value;
}
+
+ /**
+ * {@inheritDoc}
+ */
+ public function __toString()
+ {
+ $class = get_class($this);
+ $class = substr($class, strrpos($class, '\\')+1);
+
+ $roles = array();
+ foreach ($this->roles as $role) {
+ $roles[] = $role->getRole();
+ }
+
+ return sprintf('%s(user="%s", authenticated=%s, roles="%s")', $class, $this->getUsername(), json_encode($this->authenticated), implode(', ', $roles));
+ }
}
diff --git a/Core/Authentication/Token/TokenInterface.php b/Core/Authentication/Token/TokenInterface.php
index add550f..63e2243 100644
--- a/Core/Authentication/Token/TokenInterface.php
+++ b/Core/Authentication/Token/TokenInterface.php
@@ -22,6 +22,15 @@ use Symfony\Component\Security\Core\User\UserInterface;
interface TokenInterface extends \Serializable
{
/**
+ * Returns a string representation ofthe Token.
+ *
+ * This is only to be used for debugging purposes.
+ *
+ * @return string
+ */
+ function __toString();
+
+ /**
* Returns the user roles.
*
* @return Role[] An array of Role instances.