コード例 #1
0
 /**
  * Returns the specified property.
  *
  * If the node has a content object attached, the property will be fetched
  * there if it is gettable.
  *
  * @param string $propertyName Name of the property
  * @param boolean $returnNodesAsIdentifiers If enabled, references to nodes are returned as node identifiers instead of NodeData objects
  * @return mixed value of the property
  * @api
  */
 public function getProperty($propertyName, $returnNodesAsIdentifiers = false)
 {
     $value = $this->nodeData->getProperty($propertyName);
     if (!empty($value)) {
         $nodeType = $this->getNodeType();
         if ($nodeType->hasConfiguration('properties.' . $propertyName)) {
             $expectedPropertyType = $nodeType->getPropertyType($propertyName);
             switch ($expectedPropertyType) {
                 case 'references':
                     if ($returnNodesAsIdentifiers === false) {
                         $nodes = array();
                         foreach ($value as $nodeIdentifier) {
                             $node = $this->context->getNodeByIdentifier($nodeIdentifier);
                             // $node can be NULL if the node is not visible according to the current content context:
                             if ($node !== null) {
                                 $nodes[] = $node;
                             }
                         }
                         $value = $nodes;
                     }
                     break;
                 case 'reference':
                     if ($returnNodesAsIdentifiers === false) {
                         $value = $this->context->getNodeByIdentifier($value);
                     }
                     break;
                 default:
                     $value = $this->propertyMapper->convert($value, $expectedPropertyType);
                     break;
             }
         }
     }
     return $value;
 }
コード例 #2
0
 /**
  * Returns TRUE if the given node has the property and the value is not empty.
  *
  * @param \TYPO3\TYPO3CR\Domain\Model\NodeData $node
  * @return boolean
  */
 public function matches(\TYPO3\TYPO3CR\Domain\Model\NodeData $node)
 {
     if ($node->hasProperty($this->propertyName)) {
         $propertyValue = $node->getProperty($this->propertyName);
         return !empty($propertyValue);
     }
     return FALSE;
 }
コード例 #3
0
 /**
  * Returns TRUE if the given node has the property and the value is not empty.
  *
  * @param NodeData $node
  * @return boolean
  */
 public function matches(NodeData $node)
 {
     if ($node->hasProperty($this->propertyName)) {
         $propertyValue = $node->getProperty($this->propertyName);
         return !empty($propertyValue);
     }
     return false;
 }
コード例 #4
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();
 }
コード例 #5
0
    /**
     * @test
     * @expectedException \TYPO3\TYPO3CR\Exception\NodeException
     */
    public function getPropertyThrowsAnExceptionIfTheSpecifiedPropertyDoesNotExistInTheContentObject()
    {
        $className = uniqid('Test');
        eval('
			class ' . $className . ' {
				public $title = "My Title";
			}
		');
        $contentObject = new $className();
        $this->nodeData->setContentObject($contentObject);
        $this->nodeData->getProperty('foo');
    }
コード例 #6
0
 /**
  * If AssetList contains only 1 file, and it's of type Audio, turn it into targetNodeType
  *
  * @param \TYPO3\TYPO3CR\Domain\Model\NodeData $node
  * @return void
  */
 public function execute(\TYPO3\TYPO3CR\Domain\Model\NodeData $node)
 {
     $assets = $node->getProperty($this->sourcePropertyName);
     if (count($assets) === 1) {
         $asset = $assets[0];
         if ($asset instanceof $this->assetType) {
             $nodeType = $this->nodeTypeManager->getNodeType($this->targetNodeType);
             $node->setNodeType($nodeType);
             $node->setProperty($this->targetPropertyName, $asset);
             $node->removeProperty($this->sourcePropertyName);
             echo "Converted AssetList with asset of type" . $this->assetType . " to node of type " . $this->targetNodeType . "\n";
         }
     }
 }
コード例 #7
0
 /**
  * Returns the specified property.
  *
  * If the node has a content object attached, the property will be fetched
  * there if it is gettable.
  *
  * @param string $propertyName Name of the property
  * @param boolean $returnNodesAsIdentifiers If enabled, references to nodes are returned as node identifiers instead of NodeInterface instances
  * @return mixed value of the property
  * @api
  */
 public function getProperty($propertyName, $returnNodesAsIdentifiers = false)
 {
     $value = $this->nodeData->getProperty($propertyName);
     if (empty($value)) {
         return $value;
     }
     $nodeType = $this->getNodeType();
     if (!$nodeType->hasConfiguration('properties.' . $propertyName)) {
         return $value;
     }
     $expectedPropertyType = $nodeType->getPropertyType($propertyName);
     if ($expectedPropertyType === 'references') {
         return $returnNodesAsIdentifiers ? $value : $this->resolvePropertyReferences($value);
     }
     if ($expectedPropertyType === 'reference') {
         return $returnNodesAsIdentifiers ? $value : $this->context->getNodeByIdentifier($value);
     }
     return $this->propertyMapper->convert($value, $expectedPropertyType);
 }
 /**
  * Change the property on the given node.
  *
  * @param NodeData $node
  * @return NodeData
  */
 public function execute(NodeData $node)
 {
     $reference = (string) $node->getProperty('plugin');
     $workspace = $node->getWorkspace();
     do {
         if ($this->reverse === false && preg_match(NodeInterface::MATCH_PATTERN_PATH, $reference)) {
             $pluginNode = $this->nodeDataRepository->findOneByPath($reference, $node->getWorkspace());
         } else {
             $pluginNode = $this->nodeDataRepository->findOneByIdentifier($reference, $node->getWorkspace());
         }
         if (isset($pluginNode)) {
             break;
         }
         $workspace = $workspace->getBaseWorkspace();
     } while ($workspace && $workspace->getName() !== 'live');
     if (isset($pluginNode)) {
         $node->setProperty('plugin', $this->reverse === false ? $pluginNode->getIdentifier() : $pluginNode->getPath());
     }
     return $node;
 }
コード例 #9
0
ファイル: Node.php プロジェクト: radmiraal/TYPO3.TYPO3CR
 /**
  * Returns the specified property.
  *
  * If the node has a content object attached, the property will be fetched
  * there if it is gettable.
  *
  * @param string $propertyName Name of the property
  * @param boolean $returnNodesAsIdentifiers If enabled, references to nodes are returned as node identifiers instead of NodeData objects
  * @return mixed value of the property
  * @api
  */
 public function getProperty($propertyName, $returnNodesAsIdentifiers = FALSE)
 {
     $value = $this->nodeData->getProperty($propertyName, $returnNodesAsIdentifiers, $this->context);
     if (!empty($value) && $returnNodesAsIdentifiers === FALSE) {
         switch ($this->getNodeType()->getPropertyType($propertyName)) {
             case 'references':
                 $nodes = array();
                 foreach ($value as $nodeData) {
                     $node = $this->nodeFactory->createFromNodeData($nodeData, $this->context);
                     // $node can be NULL if the node is not visible according to the current content context:
                     if ($node !== NULL) {
                         $nodes[] = $node;
                     }
                 }
                 $value = $nodes;
                 break;
             case 'reference':
                 $value = $this->nodeFactory->createFromNodeData($value, $this->context);
                 break;
         }
     }
     return $value;
 }
コード例 #10
0
 /**
  * Renames the configured property to the new name.
  *
  * @param NodeData $node
  * @return void
  */
 public function execute(NodeData $node)
 {
     $node->setProperty($this->newPropertyName, $node->getProperty($this->oldPropertyName));
     $node->removeProperty($this->oldPropertyName);
 }
コード例 #11
0
 /**
  * Strips tags on the value of the property to work on.
  *
  * @param NodeData $node
  * @return void
  */
 public function execute(NodeData $node)
 {
     $node->setProperty($this->propertyName, strip_tags($node->getProperty($this->propertyName)));
 }
 /**
  * Change the property on the given node.
  *
  * @param \TYPO3\TYPO3CR\Domain\Model\NodeData $node
  * @return void
  */
 public function execute(\TYPO3\TYPO3CR\Domain\Model\NodeData $node)
 {
     $currentPropertyValue = $node->getProperty($this->propertyName);
     $newPropertyValue = strtolower($currentPropertyValue);
     $node->setProperty($this->propertyName, $newPropertyValue);
 }
コード例 #13
0
 /**
  * Strips tags on the value of the property to work on.
  *
  * @param \TYPO3\TYPO3CR\Domain\Model\NodeData $node
  * @return void
  */
 public function execute(\TYPO3\TYPO3CR\Domain\Model\NodeData $node)
 {
     $node->setProperty($this->propertyName, strip_tags($node->getProperty($this->propertyName)));
 }
コード例 #14
0
 /**
  * Renames the configured property to the new name.
  *
  * @param \TYPO3\TYPO3CR\Domain\Model\NodeData $node
  * @return void
  */
 public function execute(\TYPO3\TYPO3CR\Domain\Model\NodeData $node)
 {
     $node->setProperty($this->newPropertyName, $node->getProperty($this->oldPropertyName));
     $node->removeProperty($this->oldPropertyName);
 }
コード例 #15
0
 /**
  * Change the property on the given node.
  *
  * @param NodeData $node
  * @return void
  */
 public function execute(NodeData $node)
 {
     $currentPropertyValue = $node->getProperty($this->propertyName);
     $newValueWithReplacedCurrentValue = str_replace($this->currentValuePlaceholder, $currentPropertyValue, $this->newValue);
     $newValueWithReplacedSearch = str_replace($this->search, $this->replace, $newValueWithReplacedCurrentValue);
     $node->setProperty($this->propertyName, $newValueWithReplacedSearch);
 }
コード例 #16
0
 /**
  * @param \TYPO3\TYPO3CR\Domain\Model\NodeData $node
  * @return void
  */
 public function execute(\TYPO3\TYPO3CR\Domain\Model\NodeData $node)
 {
     $sourcePropertyValue = $node->getProperty($this->sourcePropertyName);
     $node->setProperty($this->targetPropertyName, [$sourcePropertyValue]);
 }
コード例 #17
0
 /**
  * Change the property on the given node.
  *
  * @param NodeData $node
  * @return NodeData
  */
 public function execute(NodeData $node)
 {
     $headlineTag = substr($node->getProperty('type'), 0, 2);
     $node->setProperty('title', sprintf('<%1$s>%2$s</%1$s>', $headlineTag, $node->getProperty('title')));
     return $node;
 }