toArray() public method

returns an array of property value pairs.
Deprecation: Use the serializer instead
public toArray ( boolean $complete = true ) : array
$complete boolean True if result should be representation of full node
return array
Ejemplo n.º 1
0
 /**
  * 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;
 }
Ejemplo n.º 2
0
 /**
  * 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;
 }