Ejemplo n.º 1
0
 /**
  * Returns TRUE if the given node has the property and the value is not empty.
  *
  * @param \TYPO3\TYPO3CR\Domain\Model\NodeInterface $node
  * @return boolean
  */
 public function matches(\TYPO3\TYPO3CR\Domain\Model\NodeInterface $node)
 {
     if ($node->hasProperty($this->propertyName)) {
         $propertyValue = $node->getProperty($this->propertyName);
         return !empty($propertyValue);
     }
     return FALSE;
 }
 /**
  * {@inheritdoc}
  *
  * @param FlowQuery $flowQuery the FlowQuery object
  * @param array $arguments the arguments for this operation
  * @return mixed|null if the operation is final, the return value
  */
 public function evaluate(FlowQuery $flowQuery, array $arguments)
 {
     $imagePropertyName = $arguments[0];
     if ($this->contextNode->hasProperty($imagePropertyName)) {
         $image = $this->contextNode->getProperty($imagePropertyName);
         if ($image instanceof ImageVariant) {
             $image = $image->getOriginalAsset();
         }
         if ($image instanceof Image) {
             $identifier = $image->getIdentifier();
             $nodeData = $this->metaDataRepository->findOneByAssetIdentifier($identifier, $this->contextNode->getContext()->getWorkspace());
             if ($nodeData instanceof NodeData) {
                 return $this->nodeFactory->createFromNodeData($nodeData, $this->contextNode->getContext());
             }
         }
     }
     return null;
 }
Ejemplo n.º 3
0
 /**
  * Extract comments and deserialize them
  *
  * @param NodeInterface|NodeData $nodeOrNodeData
  * @return array
  */
 protected function extractComments($nodeOrNodeData)
 {
     if ($nodeOrNodeData->hasProperty('comments')) {
         $comments = $nodeOrNodeData->getProperty('comments');
         if (is_string($comments) && strlen($comments) > 0) {
             return json_decode($comments, TRUE);
         }
     }
     return array();
 }
 /**
  * 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('TYPO3.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 TYPO3.Neos:Document][uriPathSegment="' . $possibleUriPathSegment . '"]')->count() > 0) {
             $possibleUriPathSegment = $initialUriPathSegment . '-' . $i++;
         }
         $node->setProperty('uriPathSegment', $possibleUriPathSegment);
     }
 }
 /**
  * Renders a request path based on the "uriPathSegment" properties of the nodes leading to the given node.
  *
  * @param NodeInterface $siteNode Top level node, corresponds to the top level of the request path
  * @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 $siteNode, NodeInterface $node)
 {
     if ($siteNode === $node) {
         return '';
     }
     $requestPathSegments = array();
     while ($siteNode !== $node && $node instanceof NodeInterface) {
         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));
 }
Ejemplo n.º 6
0
 /**
  * If the given node has no property this transformation should work on, this
  * returns TRUE.
  *
  * @param \TYPO3\TYPO3CR\Domain\Model\NodeInterface $node
  * @return boolean
  */
 public function isTransformable(\TYPO3\TYPO3CR\Domain\Model\NodeInterface $node)
 {
     return !$node->hasProperty($this->newPropertyName);
 }