diff options
Diffstat (limited to 'Core/Role')
-rw-r--r-- | Core/Role/Role.php | 18 | ||||
-rw-r--r-- | Core/Role/SwitchUserRole.php | 18 |
2 files changed, 35 insertions, 1 deletions
diff --git a/Core/Role/Role.php b/Core/Role/Role.php index 5b50981..7f16302 100644 --- a/Core/Role/Role.php +++ b/Core/Role/Role.php @@ -17,7 +17,7 @@ namespace Symfony\Component\Security\Core\Role; * * @author Fabien Potencier <fabien@symfony.com> */ -class Role implements RoleInterface +class Role implements RoleInterface, \Serializable { private $role; @@ -38,4 +38,20 @@ class Role implements RoleInterface { return $this->role; } + + /** + * {@inheritdoc} + */ + public function serialize() + { + return serialize($this->role); + } + + /** + * {@inheritdoc} + */ + public function unserialize($serialized) + { + $this->role = unserialize($serialized); + } } diff --git a/Core/Role/SwitchUserRole.php b/Core/Role/SwitchUserRole.php index c679584..3076f34 100644 --- a/Core/Role/SwitchUserRole.php +++ b/Core/Role/SwitchUserRole.php @@ -45,4 +45,22 @@ class SwitchUserRole extends Role { return $this->source; } + + /** + * {@inheritdoc} + */ + public function serialize() + { + return serialize(array(parent::serialize(), $this->source)); + } + + /** + * {@inheritdoc} + */ + public function unserialize($serialized) + { + list($parent, $this->source) = unserialize($serialized); + + parent::unserialize($parent); + } } |