/** * @test */ public function propertyFunctionsUseAContentObjectIfOneHasBeenDefined() { $this->inject($this->nodeData, 'persistenceManager', $this->createMock('TYPO3\\Flow\\Persistence\\PersistenceManagerInterface')); $className = uniqid('Test'); eval(' class ' . $className . ' { public $title = "My Title"; public $body = "My Body"; } '); $contentObject = new $className(); $this->nodeData->setContentObject($contentObject); $this->assertTrue($this->nodeData->hasProperty('title')); $this->assertFalse($this->nodeData->hasProperty('iltfh')); $this->assertEquals('My Body', $this->nodeData->getProperty('body')); $this->assertEquals('My Title', $this->nodeData->getProperty('title')); $this->assertEquals(array('title' => 'My Title', 'body' => 'My Body'), $this->nodeData->getProperties()); $actualPropertyNames = $this->nodeData->getPropertyNames(); sort($actualPropertyNames); $this->assertEquals(array('body', 'title'), $actualPropertyNames); $this->nodeData->setProperty('title', 'My Other Title'); $this->nodeData->setProperty('body', 'My Other Body'); $this->assertEquals('My Other Body', $this->nodeData->getProperty('body')); $this->assertEquals('My Other Title', $this->nodeData->getProperty('title')); }
/** * 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; }
/** * 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; }
/** * 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(); }
/** * If this node has a property with the given name. * * If the node has a content object attached, the property will be checked * there. * * @param string $propertyName * @return boolean * @api */ public function hasProperty($propertyName) { return $this->nodeData->hasProperty($propertyName); }
/** * Returns TRUE if the given node has the property to work on. * * @param NodeData $node * @return boolean */ public function isTransformable(NodeData $node) { return $node->hasProperty($this->propertyName); }
/** * Returns TRUE if the given node has the property to work on. * * @param \TYPO3\TYPO3CR\Domain\Model\NodeData $node * @return boolean */ public function isTransformable(\TYPO3\TYPO3CR\Domain\Model\NodeData $node) { return $node->hasProperty($this->propertyName); }