/** * @EXT\Route( * "/properties/edit/{node}", * name="claro_resource_edit_properties", * options={"expose"=true} * ) * @EXT\Template("ClarolineCoreBundle:Resource:propertiesForm.html.twig") * @EXT\ParamConverter("user", options={"authenticatedUser" = true}) * * Changes the resource properties. * * @param ResourceNode $node * @param \Claroline\CoreBundle\Entity\User $user * * @throws \Symfony\Component\Security\Core\Exception\AccessDeniedException * * @return SResponse */ public function changePropertiesAction(ResourceNode $node, User $user) { $collection = new ResourceCollection([$node]); $this->checkAccess('ADMINISTRATE', $collection); $creatorUsername = $node->getCreator()->getUsername(); $wasPublished = $node->isPublished(); $wasPublishedToPortal = $node->isPublishedToPortal(); $form = $this->formFactory->create(new ResourcePropertiesType($creatorUsername, $this->translator), $node); $form->handleRequest($this->request); if ($form->isValid()) { $name = $form->get('name')->getData(); $file = $form->get('newIcon')->getData(); $isRecursive = $this->request->get('isRecursive'); if ($file) { $this->resourceManager->changeIcon($node, $file); } $this->resourceManager->rename($node, $name); if ($isRecursive) { $accessibleFrom = $form->get('accessibleFrom')->getData(); $accessibleUntil = $form->get('accessibleUntil')->getData(); $this->resourceManager->changeAccessibilityDate($node, $accessibleFrom, $accessibleUntil); } if ($node->isPublished() !== $wasPublished) { $eventName = "publication_change_{$node->getResourceType()->getName()}"; $resource = $this->resourceManager->getResourceFromNode($node); $this->dispatcher->dispatch($eventName, 'PublicationChange', [$resource]); } if ($this->hasAccess('ADMINISTRATE', $collection) && $node->isPublishedToPortal() && !$wasPublishedToPortal) { $this->resourceManager->openResourceForPortal($node); } $arrayNode = $this->resourceManager->toArray($node, $this->tokenStorage->getToken()); return new JsonResponse($arrayNode); } $isDir = $node->getResourceType()->getName() === 'directory'; return ['form' => $form->createView(), 'nodeId' => $node->getId(), 'isDir' => $isDir]; }