components/AuthBehavior.php
public function flattenPermissions($permissions)
    {
        $flattened = array();
        foreach ($permissions as $itemName => $itemPermissions) {
            $flattened[$itemName] = $itemPermissions;

            if (isset($itemPermissions['children'])) {
                $children = $itemPermissions['children'];
                unset($itemPermissions['children']); // not needed in a flat tree
                $flattened = array_merge($flattened, $this->flattenPermissions($children));
            }

            if (isset($itemPermissions['parents'])) {
                $parents = $itemPermissions['parents'];
                unset($itemPermissions['parents']);
                $flattened = array_merge($flattened, $this->flattenPermissions($parents));
            }
        }
        return $flattened;
    }
public function flattenPermissions($permissions)
    {
        $flattened = array();
        foreach ($permissions as $itemName => $itemPermissions) {
            $flattened[$itemName] = $itemPermissions;

            if (isset($itemPermissions['children'])) {
                $children = $itemPermissions['children'];
                unset($itemPermissions['children']); // not needed in a flat tree
                $flattened = array_merge($flattened, $this->flattenPermissions($children));
            }

            if (isset($itemPermissions['parents'])) {
                $parents = $itemPermissions['parents'];
                unset($itemPermissions['parents']);
                $flattened = array_merge($flattened, $this->flattenPermissions($parents));
            }
        }
        return $flattened;
    }
public function flattenPermissions ( $ permissions ) { $ flattened = array ( ) ; foreach ( $ permissions as $ itemName => $ itemPermissions ) { $ flattened [ $ itemName ] = $ itemPermissions ; if ( isset ( $ itemPermissions [ 'children' ] ) ) { $ children = $ itemPermissions [ 'children' ] ; unset ( $ itemPermissions [ 'children' ] ) ; // not needed in a flat tree $ flattened = array_merge ( $ flattened , $ this -> flattenPermissions ( $ children ) ) ; } if ( isset ( $ itemPermissions [ 'parents' ] ) ) { $ parents = $ itemPermissions [ 'parents' ] ; unset ( $ itemPermissions [ 'parents' ] ) ; $ flattened = array_merge ( $ flattened , $ this -> flattenPermissions ( $ parents ) ) ; } } return $ flattened ; }
Flattens the given permission tree.
@param array $permissions the permissions tree.
@return array the permissions.
Flattens the given permission tree .