getProperty() public method

If the node has a content object attached, the property will be fetched there if it is gettable.
public getProperty ( string $propertyName ) : mixed
$propertyName string Name of the property
return mixed value of the property
 /**
  * Resolves a shortcut node to the target. The return value can be
  *
  * * a NodeInterface instance if the target is a node or a node:// URI
  * * a string (in case the target is a plain text URI or an asset:// URI)
  * * NULL in case the shortcut cannot be resolved
  *
  * @param NodeInterface $node
  * @return NodeInterface|string|NULL
  */
 public function resolveShortcutTarget(NodeInterface $node)
 {
     $infiniteLoopPrevention = 0;
     while ($node->getNodeType()->isOfType('Neos.Neos:Shortcut') && $infiniteLoopPrevention < 50) {
         $infiniteLoopPrevention++;
         switch ($node->getProperty('targetMode')) {
             case 'selectedTarget':
                 $target = $node->getProperty('target');
                 if ($this->linkingService->hasSupportedScheme($target)) {
                     $targetObject = $this->linkingService->convertUriToObject($target, $node);
                     if ($targetObject instanceof NodeInterface) {
                         $node = $targetObject;
                     } elseif ($targetObject instanceof AssetInterface) {
                         return $this->linkingService->resolveAssetUri($target);
                     }
                 } else {
                     return $target;
                 }
                 break;
             case 'parentNode':
                 $node = $node->getParent();
                 break;
             case 'firstChildNode':
             default:
                 $childNodes = $node->getChildNodes('Neos.Neos:Document');
                 if ($childNodes !== array()) {
                     $node = reset($childNodes);
                 } else {
                     return null;
                 }
         }
     }
     return $node;
 }
 /**
  * Sets the best possible uriPathSegment for the given Node.
  * Will use an already set uriPathSegment or alternatively the node name as base,
  * then checks if the uriPathSegment already exists on the same level and appends a counter until a unique path segment was found.
  *
  * @param NodeInterface $node
  * @return void
  */
 public static function setUniqueUriPathSegment(NodeInterface $node)
 {
     if ($node->getNodeType()->isOfType('Neos.Neos:Document')) {
         $q = new FlowQuery(array($node));
         $q = $q->context(array('invisibleContentShown' => true, 'removedContentShown' => true, 'inaccessibleContentShown' => true));
         $possibleUriPathSegment = $initialUriPathSegment = !$node->hasProperty('uriPathSegment') ? $node->getName() : $node->getProperty('uriPathSegment');
         $i = 1;
         while ($q->siblings('[instanceof Neos.Neos:Document][uriPathSegment="' . $possibleUriPathSegment . '"]')->count() > 0) {
             $possibleUriPathSegment = $initialUriPathSegment . '-' . $i++;
         }
         $node->setProperty('uriPathSegment', $possibleUriPathSegment);
     }
 }
 /**
  * Returns the plugin namespace that will be prefixed to plugin parameters in URIs.
  * By default this is <plugin_class_name>
  *
  * @return string
  */
 protected function getPluginNamespace()
 {
     if ($this->getArgumentNamespace() !== null) {
         return $this->getArgumentNamespace();
     }
     if ($this->node instanceof NodeInterface) {
         $nodeArgumentNamespace = $this->node->getProperty('argumentNamespace');
         if ($nodeArgumentNamespace !== null) {
             return $nodeArgumentNamespace;
         }
         $nodeArgumentNamespace = $this->node->getNodeType()->getName();
         $nodeArgumentNamespace = str_replace(':', '-', $nodeArgumentNamespace);
         $nodeArgumentNamespace = str_replace('.', '_', $nodeArgumentNamespace);
         $nodeArgumentNamespace = strtolower($nodeArgumentNamespace);
         return $nodeArgumentNamespace;
     }
     $argumentNamespace = str_replace(array(':', '.', '\\'), array('_', '_', '_'), $this->getPackage() . '_' . $this->getSubpackage() . '-' . $this->getController());
     $argumentNamespace = strtolower($argumentNamespace);
     return $argumentNamespace;
 }
Esempio n. 4
0
 /**
  * Returns the rendered content of this plugin
  *
  * @return string The rendered content as a string
  * @throws StopActionException
  */
 public function evaluate()
 {
     $currentContext = $this->tsRuntime->getCurrentContext();
     $this->pluginViewNode = $currentContext['node'];
     /** @var $parentResponse Response */
     $parentResponse = $this->tsRuntime->getControllerContext()->getResponse();
     $pluginResponse = new Response($parentResponse);
     $pluginRequest = $this->buildPluginRequest();
     if ($pluginRequest->getControllerObjectName() === '') {
         $message = 'Master View not selected';
         if ($this->pluginViewNode->getProperty('plugin')) {
             $message = 'Plugin View not selected';
         }
         if ($this->pluginViewNode->getProperty('view')) {
             $message = 'Master View or Plugin View not found';
         }
         return $this->pluginViewNode->getContext()->getWorkspaceName() !== 'live' || $this->objectManager->getContext()->isDevelopment() ? '<p>' . $message . '</p>' : '<!-- ' . $message . '-->';
     }
     $this->dispatcher->dispatch($pluginRequest, $pluginResponse);
     return $pluginResponse->getContent();
 }
 /**
  * @param NodeInterface $node
  * @param boolean $expand
  * @param array $children
  * @param boolean $hasChildNodes
  * @param boolean $matched
  * @return array
  */
 public function collectTreeNodeData(NodeInterface $node, $expand = true, array $children = array(), $hasChildNodes = false, $matched = false)
 {
     $isTimedPage = false;
     $now = new \DateTime();
     $now = $now->getTimestamp();
     $hiddenBeforeDateTime = $node->getHiddenBeforeDateTime();
     $hiddenAfterDateTime = $node->getHiddenAfterDateTime();
     if ($hiddenBeforeDateTime !== null && $hiddenBeforeDateTime->getTimestamp() > $now) {
         $isTimedPage = true;
     }
     if ($hiddenAfterDateTime !== null) {
         $isTimedPage = true;
     }
     $classes = array();
     if ($isTimedPage === true && $node->isHidden() === false) {
         array_push($classes, 'neos-timedVisibility');
     }
     if ($node->isHidden() === true) {
         array_push($classes, 'neos-hidden');
     }
     if ($node->isHiddenInIndex() === true) {
         array_push($classes, 'neos-hiddenInIndex');
     }
     if ($matched) {
         array_push($classes, 'neos-matched');
     }
     $uriBuilder = $this->controllerContext->getUriBuilder();
     $nodeType = $node->getNodeType();
     $nodeTypeConfiguration = $nodeType->getFullConfiguration();
     if ($node->getNodeType()->isOfType('Neos.Neos:Document')) {
         $uriForNode = $uriBuilder->reset()->setFormat('html')->setCreateAbsoluteUri(true)->uriFor('show', array('node' => $node), 'Frontend\\Node', 'Neos.Neos');
     } else {
         $uriForNode = '#';
     }
     $label = $node->getLabel();
     $nodeTypeLabel = $node->getNodeType()->getLabel();
     $treeNode = array('key' => $node->getContextPath(), 'title' => $label, 'fullTitle' => $node->getProperty('title'), 'nodeTypeLabel' => $nodeTypeLabel, 'tooltip' => '', 'href' => $uriForNode, 'isFolder' => $hasChildNodes, 'isLazy' => $hasChildNodes && !$expand, 'nodeType' => $nodeType->getName(), 'isAutoCreated' => $node->isAutoCreated(), 'expand' => $expand, 'addClass' => implode(' ', $classes), 'name' => $node->getName(), 'iconClass' => isset($nodeTypeConfiguration['ui']) && isset($nodeTypeConfiguration['ui']['icon']) ? $nodeTypeConfiguration['ui']['icon'] : '', 'isHidden' => $node->isHidden());
     if ($hasChildNodes) {
         $treeNode['children'] = $children;
     }
     return $treeNode;
 }
 /**
  * Traverses through the tree starting at the given root node and sets the uriPathSegment property derived from
  * the node label.
  *
  * @param NodeInterface $node The node where the traversal starts
  * @param boolean $dryRun
  * @return void
  */
 protected function generateUriPathSegmentsForNode(NodeInterface $node, $dryRun)
 {
     if ((string) $node->getProperty('uriPathSegment') === '') {
         $name = $node->getLabel() ?: $node->getName();
         $uriPathSegment = $this->nodeUriPathSegmentGenerator->generateUriPathSegment($node);
         if ($dryRun === false) {
             $node->setProperty('uriPathSegment', $uriPathSegment);
             $this->output->outputLine('Added missing URI path segment for "%s" (%s) => %s', array($node->getPath(), $name, $uriPathSegment));
         } else {
             $this->output->outputLine('Found missing URI path segment for "%s" (%s) => %s', array($node->getPath(), $name, $uriPathSegment));
         }
     }
     foreach ($node->getChildNodes('Neos.Neos:Document') as $childNode) {
         $this->generateUriPathSegmentsForNode($childNode, $dryRun);
     }
 }
 /**
  * Renders a request path based on the "uriPathSegment" properties of the nodes leading to the given node.
  *
  * @param NodeInterface $node The node where the generated path should lead to
  * @return string A relative request path
  * @throws Exception\MissingNodePropertyException if the given node doesn't have a "uriPathSegment" property set
  */
 protected function getRequestPathByNode(NodeInterface $node)
 {
     if ($node->getParentPath() === SiteService::SITES_ROOT_PATH) {
         return '';
     }
     $requestPathSegments = [];
     while ($node instanceof NodeInterface && $node->getParentPath() !== SiteService::SITES_ROOT_PATH) {
         if (!$node->hasProperty('uriPathSegment')) {
             throw new Exception\MissingNodePropertyException(sprintf('Missing "uriPathSegment" property for node "%s". Nodes can be migrated with the "flow node:repair" command.', $node->getPath()), 1415020326);
         }
         $pathSegment = $node->getProperty('uriPathSegment');
         $requestPathSegments[] = $pathSegment;
         $node = $node->getParent();
     }
     return implode('/', array_reverse($requestPathSegments));
 }