merged branch stof/serializable_role (PR #4925)
Commits -------1f2f866
fixed the serialization of the SwitchUserRoleb55930a
[Security] Implemented the Serializable interface in the Role class Discussion ---------- [Security] Implemented the Serializable interface in the Role class The Role class is serialized in the session for each role of the user. Implementing the Serializable interface allows to reduce the size of the data.
This commit is contained in:
commit
b0750f6dcd
@ -4,6 +4,7 @@ CHANGELOG
|
|||||||
2.1.0
|
2.1.0
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
* Added the Serializable interface on the Role class
|
||||||
* [BC BREAK] The signature of ExceptionListener has changed
|
* [BC BREAK] The signature of ExceptionListener has changed
|
||||||
* changed the HttpUtils constructor signature to take a UrlGenerator and a UrlMatcher instead of a Router
|
* changed the HttpUtils constructor signature to take a UrlGenerator and a UrlMatcher instead of a Router
|
||||||
* EncoderFactoryInterface::getEncoder() can now also take a class name as an argument
|
* EncoderFactoryInterface::getEncoder() can now also take a class name as an argument
|
||||||
|
@ -17,7 +17,7 @@ namespace Symfony\Component\Security\Core\Role;
|
|||||||
*
|
*
|
||||||
* @author Fabien Potencier <fabien@symfony.com>
|
* @author Fabien Potencier <fabien@symfony.com>
|
||||||
*/
|
*/
|
||||||
class Role implements RoleInterface
|
class Role implements RoleInterface, \Serializable
|
||||||
{
|
{
|
||||||
private $role;
|
private $role;
|
||||||
|
|
||||||
@ -38,4 +38,20 @@ class Role implements RoleInterface
|
|||||||
{
|
{
|
||||||
return $this->role;
|
return $this->role;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function serialize()
|
||||||
|
{
|
||||||
|
return serialize($this->role);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function unserialize($serialized)
|
||||||
|
{
|
||||||
|
$this->role = unserialize($serialized);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,4 +45,22 @@ class SwitchUserRole extends Role
|
|||||||
{
|
{
|
||||||
return $this->source;
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user