public function copy(Workspace $workspace, Workspace $newWorkspace, $model = false)
    {
        $transferManager = $this->container->get('claroline.manager.workspace.transfer');

        $fileBag = new FileBag();
        //these are the new workspace datas
        $data = $transferManager->serialize($workspace);
        $data = $transferManager->exportFiles($data, $fileBag, $workspace);

        if ($this->logger) {
            $transferManager->setLogger($this->logger);
        }

        if ($newWorkspace->getCode()) {
            unset($data['code']);
        }

        if ($newWorkspace->getName()) {
            unset($data['name']);
        }

        $options = [Options::LIGHT_COPY, Options::REFRESH_UUID];
        // gets entity from raw data.
        $workspace = $transferManager->deserialize($data, $newWorkspace, $options, $fileBag);
        $workspace->setIsModel($model);

        //set the manager
        $managerRole = $this->roleManager->getManagerRole($workspace);

        if ($managerRole && $workspace->getCreator()) {
            $user = $workspace->getCreator();
            $user->addRole($managerRole);
            $this->om->persist($user);
        }

        $root = $this->resourceManager->getWorkspaceRoot($workspace);

        if ($root) {
            $this->resourceManager->createRights($root);
        }

        $this->om->persist($workspace);
        $this->om->flush();

        return $workspace;
    }