Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Security] Implemented the Serializable interface in the Role class #4934

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Symfony/Component/Security/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ CHANGELOG
2.1.0
-----

* Added the Serializable interface on the Role class
* [BC BREAK] The signature of ExceptionListener has changed
* 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
Expand Down
18 changes: 17 additions & 1 deletion src/Symfony/Component/Security/Core/Role/Role.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*
* @author Fabien Potencier <[email protected]>
*/
class Role implements RoleInterface
class Role implements RoleInterface, \Serializable
{
private $role;

Expand All @@ -38,4 +38,20 @@ public function getRole()
{
return $this->role;
}

/**
* {@inheritdoc}
*/
public function serialize()
{
return serialize($this->role);
}

/**
* {@inheritdoc}
*/
public function unserialize($serialized)
{
$this->role = unserialize($serialized);
}
}
18 changes: 18 additions & 0 deletions src/Symfony/Component/Security/Core/Role/SwitchUserRole.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,22 @@ public function getSource()
{
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);
}
}