main/core/Manager/Workspace/TransferManager.php
public function serialize(Workspace $workspace)
    {
        $serialized = $this->serializer->serialize($workspace, [Options::REFRESH_UUID]);

        //if roles duplicatas, remove them
        $roles = $serialized['roles'];

        foreach ($roles as $role) {
            $uniques[$role['translationKey']] = ['type' => $role['type']];
        }

        $roles = [];
        foreach ($uniques as $key => $val) {
            $val['translationKey'] = $key;
            $roles[] = $val;
        }

        $serialized['roles'] = $roles;

        //we want to load  the ressources first
        $ot = $workspace->getOrderedTools()->toArray();

        $idx = 0;

        foreach ($ot as $key => $tool) {
            if ('resource_manager' === $tool->getName()) {
                $idx = $key;
            }
        }

        $first = $ot[$idx];
        unset($ot[$idx]);
        array_unshift($ot, $first);

        $serialized['orderedTools'] = array_map(function (OrderedTool $tool) {
            $data = $this->ots->serialize($tool, [Options::SERIALIZE_TOOL, Options::REFRESH_UUID]);

            return $data;
        }, $ot);

        return $serialized;
    }
public function serialize(Workspace $workspace)
    {
        $serialized = $this->serializer->serialize($workspace, [Options::REFRESH_UUID]);

        //if roles duplicatas, remove them
        $roles = $serialized['roles'];

        foreach ($roles as $role) {
            $uniques[$role['translationKey']] = ['type' => $role['type']];
        }

        $roles = [];
        foreach ($uniques as $key => $val) {
            $val['translationKey'] = $key;
            $roles[] = $val;
        }

        $serialized['roles'] = $roles;

        //we want to load  the ressources first
        $ot = $workspace->getOrderedTools()->toArray();

        $idx = 0;

        foreach ($ot as $key => $tool) {
            if ('resource_manager' === $tool->getName()) {
                $idx = $key;
            }
        }

        $first = $ot[$idx];
        unset($ot[$idx]);
        array_unshift($ot, $first);

        $serialized['orderedTools'] = array_map(function (OrderedTool $tool) {
            $data = $this->ots->serialize($tool, [Options::SERIALIZE_TOOL, Options::REFRESH_UUID]);

            return $data;
        }, $ot);

        return $serialized;
    }
public function serialize ( Workspace $ workspace ) { $ serialized = $ this -> serializer -> serialize ( $ workspace , [ Options :: REFRESH_UUID ] ) ; //if roles duplicatas, remove them $ roles = $ serialized [ 'roles' ] ; foreach ( $ roles as $ role ) { $ uniques [ $ role [ 'translationKey' ] ] = [ 'type' => $ role [ 'type' ] ] ; } $ roles = [ ] ; foreach ( $ uniques as $ key => $ val ) { $ val [ 'translationKey' ] = $ key ; $ roles [ ] = $ val ; } $ serialized [ 'roles' ] = $ roles ; //we want to load  the ressources first $ ot = $ workspace -> getOrderedTools ( ) -> toArray ( ) ; $ idx = 0 ; foreach ( $ ot as $ key => $ tool ) { if ( 'resource_manager' === $ tool -> getName ( ) ) { $ idx = $ key ; } } $ first = $ ot [ $ idx ] ; unset ( $ ot [ $ idx ] ) ; array_unshift ( $ ot , $ first ) ; $ serialized [ 'orderedTools' ] = array_map ( function ( OrderedTool $ tool ) { $ data = $ this -> ots -> serialize ( $ tool , [ Options :: SERIALIZE_TOOL , Options :: REFRESH_UUID ] ) ; return $ data ; } , $ ot ) ; return $ serialized ; }
Returns a json description of the entire workspace.

@param Workspace $workspace - the workspace to serialize

@return array - the serialized representation of the workspace
Returns a json description of the entire workspace .