getNode() public method

{@inheritDoc}
public getNode ( $selectorName = null )
Exemplo n.º 1
0
 /**
  * converts a query row to an array.
  */
 private function rowToArray(Row $row, $locale, $webspaceKey, $fields)
 {
     // reset cache
     $this->initializeExtensionCache();
     $templateName = $this->encoder->localizedSystemName('template', $locale);
     $nodeTypeName = $this->encoder->localizedSystemName('nodeType', $locale);
     // check and determine shadow-nodes
     $node = $row->getNode('page');
     $document = $this->documentManager->find($node->getIdentifier(), $locale);
     $originalDocument = $document;
     if (!$node->hasProperty($templateName) && !$node->hasProperty($nodeTypeName)) {
         return false;
     }
     $redirectType = $document->getRedirectType();
     if ($redirectType === RedirectType::INTERNAL) {
         $target = $document->getRedirectTarget();
         if ($target) {
             $url = $target->getResourceSegment();
             $document = $target;
             $node = $this->inspector->getNode($document);
         }
     }
     if ($redirectType === RedirectType::EXTERNAL) {
         $url = 'http://' . $document->getRedirectExternal();
     }
     $originLocale = $locale;
     if ($document instanceof ShadowLocaleBehavior) {
         $locale = $document->isShadowLocaleEnabled() ? $document->getShadowLocale() : $originLocale;
     }
     $nodeState = null;
     if ($document instanceof WorkflowStageBehavior) {
         $nodeState = $document->getWorkflowStage();
     }
     // if page is not piblished ignore it
     if ($nodeState !== WorkflowStage::PUBLISHED) {
         return false;
     }
     if (!isset($url)) {
         $url = $document->getResourceSegment();
     }
     if (false === $url) {
         return;
     }
     // generate field data
     $fieldsData = $this->getFieldsData($row, $node, $document, $fields[$originLocale], $document->getStructureType(), $webspaceKey, $locale);
     $structureType = $document->getStructureType();
     $shortPath = $this->inspector->getContentPath($originalDocument);
     $documentData = array('uuid' => $document->getUuid(), 'nodeType' => $redirectType, 'path' => $shortPath, 'changed' => $document->getChanged(), 'changer' => $document->getChanger(), 'created' => $document->getCreated(), 'published' => $document->getPublished(), 'creator' => $document->getCreator(), 'title' => $originalDocument->getTitle(), 'url' => $url, 'urls' => $this->inspector->getLocalizedUrlsForPage($document), 'locale' => $locale, 'webspaceKey' => $this->inspector->getWebspace($document), 'template' => $structureType, 'parent' => $this->inspector->getParent($document)->getUuid());
     if ($document instanceof OrderBehavior) {
         $documentData['order'] = $document->getSuluOrder();
     }
     return array_merge($documentData, $fieldsData);
 }