예제 #1
0
 /**
  * @EXT\Route(
  *     "/{workspaceId}/open",
  *     name="claro_workspace_open",
  *     options={"expose"=true}
  * )
  * @EXT\ParamConverter(
  *      "workspace",
  *      class="ClarolineCoreBundle:Workspace\Workspace",
  *      options={"id" = "workspaceId", "strictId" = true}
  * )
  * @SEC\PreAuthorize("canAccessWorkspace('OPEN')")
  *
  * Open the first tool of a workspace.
  *
  * @param Workspace $workspace
  * @throws AccessDeniedException
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  */
 public function openAction(Workspace $workspace)
 {
     $options = $workspace->getOptions();
     if (!is_null($options)) {
         $details = $options->getDetails();
         if (isset($details['use_workspace_opening_resource']) && $details['use_workspace_opening_resource'] && isset($details['workspace_opening_resource']) && !empty($details['workspace_opening_resource'])) {
             $resourceNode = $this->resourceManager->getById($details['workspace_opening_resource']);
             if (!is_null($resourceNode)) {
                 $this->session->set('isDesktop', false);
                 $route = $this->router->generate('claro_resource_open', array('node' => $resourceNode->getId(), 'resourceType' => $resourceNode->getResourceType()->getName()));
                 return new RedirectResponse($route);
             }
         }
     }
     $roles = $this->utils->getRoles($this->tokenStorage->getToken());
     $tool = $this->workspaceManager->getFirstOpenableTool($workspace);
     if ($tool) {
         $route = $this->router->generate('claro_workspace_open_tool', array('workspaceId' => $workspace->getId(), 'toolName' => $tool->getName()));
         return new RedirectResponse($route);
     }
     $this->throwWorkspaceDeniedException($workspace);
 }
 private function duplicateWorkspaceOptions(Workspace $source, Workspace $workspace)
 {
     $sourceOptions = $source->getOptions();
     if (!is_null($sourceOptions)) {
         $options = new WorkspaceOptions();
         $options->setWorkspace($workspace);
         $details = $sourceOptions->getDetails();
         if (!is_null($details)) {
             $details['use_workspace_opening_resource'] = false;
             $details['workspace_opening_resource'] = null;
         }
         $options->setDetails($details);
         $workspace->setOptions($options);
         $this->om->persist($options);
         $this->om->persist($workspace);
         $this->om->flush();
     }
 }