/** * Gets the relative path between 2 instances (not optimized yet). * * @param ResourceNode $root * @param ResourceNode $node * @param string $path * * @return string */ private function getRelativePath(ResourceNode $root, ResourceNode $node, $path = '') { if ($root !== $node->getParent() && $node->getParent() !== null) { $path = $node->getParent()->getName() . DIRECTORY_SEPARATOR . $path; $path = $this->getRelativePath($root, $node->getParent(), $path); } return $path; }
/** * @EXT\Route( * "/sort/{node}/at/{index}", * name="claro_resource_insert_at", * options={"expose"=true} * ) * @EXT\ParamConverter("user", options={"authenticatedUser" = true}) * * @param ResourceNode $node * @param User $user * @param integer $index * * @throws \Symfony\Component\Security\Core\Exception\AccessDeniedException * @return \Symfony\Component\HttpFoundation\Response */ public function insertAt(ResourceNode $node, User $user, $index) { if ($user !== $node->getParent()->getCreator() && !$this->authorization->isGranted('ROLE_ADMIN')) { throw new AccessDeniedException(); } $this->resourceManager->insertAtIndex($node, $index); return new Response('success', 204); }
public function getResourceElement(ResourceNode $resourceNode, Workspace $workspace, &$_files, &$_data, $setParentNull = false) { $parentId = $resourceNode->getParent() ? $resourceNode->getParent()->getId() : null; $resourceNode = $this->resourceManager->getRealTarget($resourceNode, false); $data = array(); $importer = $this->getImporterByName($resourceNode->getResourceType()->getName()); if ($importer) { $importer->setExtendedData($_data); $data = $importer->export($workspace, $_files, $this->resourceManager->getResourceFromNode($resourceNode), $_data); } if ($setParentNull) { $parentId = null; } $resElement = array('item' => array('name' => $resourceNode->getName(), 'creator' => null, 'parent' => $parentId, 'published' => $resourceNode->isPublished(), 'type' => $resourceNode->getResourceType()->getName(), 'roles' => $this->getPermsArray($resourceNode), 'uid' => $resourceNode->getId(), 'data' => $data)); if ($icon = $this->getIcon($resourceNode, $_files)) { $resElement['item']['icon'] = $icon; } return $resElement; }
public function getResourceElement(ResourceNode $resourceNode, $workspace = null, &$_files = [], &$_data = [], $setParentNull = false) { $parentId = $resourceNode->getParent() ? $resourceNode->getParent()->getId() : null; $resourceNode = $this->resourceManager->getRealTarget($resourceNode, false); $data = []; $resElement = []; $resource = $this->resourceManager->getResourceFromNode($resourceNode); if ($resource) { // We are not processing an orphan Node so we can run the export of the Resource $importer = $this->getImporterByName($resourceNode->getResourceType()->getName()); if ($importer && $workspace) { $importer->setExtendedData($_data); $data = $importer->export($workspace, $_files, $resource, $_data); } if ($setParentNull) { $parentId = null; } $resElement = ['item' => ['name' => $resourceNode->getName(), 'creator' => null, 'parent' => $parentId, 'published' => $resourceNode->isPublished(), 'type' => $resourceNode->getResourceType()->getName(), 'roles' => $this->getPermsArray($resourceNode), 'uid' => $resourceNode->getId(), 'data' => $data]]; if ($icon = $this->getIcon($resourceNode, $_files)) { $resElement['item']['icon'] = $icon; } } return $resElement; }