/** * returns finished Node (with _links and _embedded). * * @param StructureInterface $structure * @param string $webspaceKey * @param string $languageCode * @param int $depth * @param bool $complete * @param bool $excludeGhosts * @param string|null $extension * * @return array * * @deprecated This part should be split into a serialization handler and using the hateoas bundle */ protected function prepareNode(StructureInterface $structure, $webspaceKey, $languageCode, $depth = 1, $complete = true, $excludeGhosts = false, $extension = null) { $result = $structure->toArray($complete); // add default embedded property with empty nodes array $result['_embedded'] = []; $result['_embedded']['nodes'] = []; // add api links $result['_links'] = ['self' => ['href' => $this->apiBasePath . '/' . $structure->getUuid() . ($extension !== null ? '/' . $extension : '')], 'children' => ['href' => $this->apiBasePath . '?parent=' . $structure->getUuid() . '&depth=' . $depth . '&webspace=' . $webspaceKey . '&language=' . $languageCode . ($excludeGhosts === true ? '&exclude-ghosts=true' : '')]]; if ($this->tokenStorage && ($token = $this->tokenStorage->getToken())) { $result['_permissions'] = $this->accessControlManager->getUserPermissions(new SecurityCondition('sulu.webspaces.' . $webspaceKey, $languageCode, SecurityBehavior::class, $structure->getUuid()), $token->getUser()); } return $result; }
/** * returns finished Node (with _links and _embedded). * * @param StructureInterface $structure * @param string $webspaceKey * @param string $languageCode * @param int $depth * @param bool $complete * @param bool $excludeGhosts * @param string|null $extension * * @return array */ protected function prepareNode(StructureInterface $structure, $webspaceKey, $languageCode, $depth = 1, $complete = true, $excludeGhosts = false, $extension = null) { $result = $structure->toArray($complete); // add default embedded property with empty nodes array $result['_embedded'] = []; $result['_embedded']['nodes'] = []; // add api links $result['_links'] = ['self' => ['href' => $this->apiBasePath . '/' . $structure->getUuid() . ($extension !== null ? '/' . $extension : '')], 'children' => ['href' => $this->apiBasePath . '?parent=' . $structure->getUuid() . '&depth=' . $depth . '&webspace=' . $webspaceKey . '&language=' . $languageCode . ($excludeGhosts === true ? '&exclude-ghosts=true' : '')]]; return $result; }