Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
Implement Serializable on permission mask.
Browse files Browse the repository at this point in the history
  • Loading branch information
cdujeu committed Oct 5, 2015
1 parent 6c279e4 commit 1e2ab4c
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions core/src/core/classes/class.AJXP_PermissionMask.php
Expand Up @@ -22,7 +22,7 @@
defined('AJXP_EXEC') or die('Access not allowed');


class AJXP_PermissionMask implements JsonSerializable
class AJXP_PermissionMask implements JsonSerializable, Serializable
{
/**
* @var array
Expand Down Expand Up @@ -210,7 +210,7 @@ private function pathToBranch($path, $permission){
* @param string $currentRoot
* @return AJXP_Permission[]
*/
private function flattenTree($tree = null, &$pathes = null, $currentRoot=""){
public function flattenTree($tree = null, &$pathes = null, $currentRoot=""){
if($tree == null) $tree = $this->getTree();
if($pathes == null) $pathes = array();
if(!is_array($tree) || $tree == null) $tree = array();
Expand Down Expand Up @@ -264,4 +264,29 @@ function jsonSerialize()
{
return $this->flattenTree();
}

/**
* String representation of object
* @link http://php.net/manual/en/serializable.serialize.php
* @return string the string representation of the object or null
* @since 5.1.0
*/
public function serialize()
{
return serialize($this->permissionTree);
}

/**
* Constructs the object
* @link http://php.net/manual/en/serializable.unserialize.php
* @param string $serialized <p>
* The string representation of the object.
* </p>
* @return void
* @since 5.1.0
*/
public function unserialize($serialized)
{
$this->permissionTree = unserialize($serialized);
}
}

0 comments on commit 1e2ab4c

Please sign in to comment.