main/core/Manager/Workspace/Transfer/OrderedToolTransfer.php
public function deserialize(array $data, OrderedTool $orderedTool, array $options = [], Workspace $workspace = null, FileBag $bag = null)
    {
        $om = $this->container->get('claroline.persistence.object_manager');
        $tool = $om->getRepository(Tool::class)->findOneByName($data['tool']);

        if ($tool) {
            $orderedTool->setWorkspace($workspace);
            $orderedTool->setTool($tool);
            $orderedTool->setName($data['name']);
            $orderedTool->setOrder($data['position']);

            foreach ($data['restrictions'] as $restriction) {
                if (isset($restriction['role']['name'])) {
                    $role = $om->getRepository(Role::class)->findOneBy(['name' => $restriction['role']['name']]);
                } else {
                    $role = $om->getRepository(Role::class)->findOneBy([
                        'translationKey' => $restriction['role']['translationKey'],
                        'workspace' => $workspace->getId(),
                    ]);
                }

                $rights = new ToolRights();
                $rights->setRole($role);
                $rights->setMask($restriction['mask']);
                $rights->setOrderedTool($orderedTool);
                $om->persist($rights);
            }

            //use event instead maybe ? or tagged service
            $serviceName = 'claroline.transfer.'.$orderedTool->getTool()->getName();

            if ($this->container->has($serviceName)) {
                $importer = $this->container->get($serviceName);
                if (method_exists($importer, 'setLogger')) {
                    $importer->setLogger($this->logger);
                }
                if (isset($data['data'])) {
                    $importer->deserialize($data['data'], $orderedTool->getWorkspace(), [Options::REFRESH_UUID], $bag);
                }
            }
        }
    }
public function deserialize(array $data, OrderedTool $orderedTool, array $options = [], Workspace $workspace = null, FileBag $bag = null)
    {
        $om = $this->container->get('claroline.persistence.object_manager');
        $tool = $om->getRepository(Tool::class)->findOneByName($data['tool']);

        if ($tool) {
            $orderedTool->setWorkspace($workspace);
            $orderedTool->setTool($tool);
            $orderedTool->setName($data['name']);
            $orderedTool->setOrder($data['position']);

            foreach ($data['restrictions'] as $restriction) {
                if (isset($restriction['role']['name'])) {
                    $role = $om->getRepository(Role::class)->findOneBy(['name' => $restriction['role']['name']]);
                } else {
                    $role = $om->getRepository(Role::class)->findOneBy([
                        'translationKey' => $restriction['role']['translationKey'],
                        'workspace' => $workspace->getId(),
                    ]);
                }

                $rights = new ToolRights();
                $rights->setRole($role);
                $rights->setMask($restriction['mask']);
                $rights->setOrderedTool($orderedTool);
                $om->persist($rights);
            }

            //use event instead maybe ? or tagged service
            $serviceName = 'claroline.transfer.'.$orderedTool->getTool()->getName();

            if ($this->container->has($serviceName)) {
                $importer = $this->container->get($serviceName);
                if (method_exists($importer, 'setLogger')) {
                    $importer->setLogger($this->logger);
                }
                if (isset($data['data'])) {
                    $importer->deserialize($data['data'], $orderedTool->getWorkspace(), [Options::REFRESH_UUID], $bag);
                }
            }
        }
    }
public function deserialize ( array $ data , OrderedTool $ orderedTool , array $ options = [ ] , Workspace $ workspace = null , FileBag $ bag = null ) { $ om = $ this -> container -> get ( 'claroline.persistence.object_manager' ) ; $ tool = $ om -> getRepository ( Tool :: class ) -> findOneByName ( $ data [ 'tool' ] ) ; if ( $ tool ) { $ orderedTool -> setWorkspace ( $ workspace ) ; $ orderedTool -> setTool ( $ tool ) ; $ orderedTool -> setName ( $ data [ 'name' ] ) ; $ orderedTool -> setOrder ( $ data [ 'position' ] ) ; foreach ( $ data [ 'restrictions' ] as $ restriction ) { if ( isset ( $ restriction [ 'role' ] [ 'name' ] ) ) { $ role = $ om -> getRepository ( Role :: class ) -> findOneBy ( [ 'name' => $ restriction [ 'role' ] [ 'name' ] ] ) ; } else { $ role = $ om -> getRepository ( Role :: class ) -> findOneBy ( [ 'translationKey' => $ restriction [ 'role' ] [ 'translationKey' ] , 'workspace' => $ workspace -> getId ( ) , ] ) ; } $ rights = new ToolRights ( ) ; $ rights -> setRole ( $ role ) ; $ rights -> setMask ( $ restriction [ 'mask' ] ) ; $ rights -> setOrderedTool ( $ orderedTool ) ; $ om -> persist ( $ rights ) ; } //use event instead maybe ? or tagged service $ serviceName = 'claroline.transfer.' . $ orderedTool -> getTool ( ) -> getName ( ) ; if ( $ this -> container -> has ( $ serviceName ) ) { $ importer = $ this -> container -> get ( $ serviceName ) ; if ( method_exists ( $ importer , 'setLogger' ) ) { $ importer -> setLogger ( $ this -> logger ) ; } if ( isset ( $ data [ 'data' ] ) ) { $ importer -> deserialize ( $ data [ 'data' ] , $ orderedTool -> getWorkspace ( ) , [ Options :: REFRESH_UUID ] , $ bag ) ; } } } }
only work for creation... other not supported. It's not a true Serializer anyway atm
only work for creation ... other not supported . It s not a true Serializer anyway atm