/** * Removes the specified property. * * If the node has a content object attached, the property will not be removed on * that object if it exists. * * @param string $propertyName Name of the property * @return void * @throws NodeException if the node does not contain the specified property */ public function removeProperty($propertyName) { if (!$this->isNodeDataMatchingContext()) { $this->materializeNodeData(); } if (!$this->hasProperty($propertyName)) { return; } $this->nodeData->removeProperty($propertyName); $this->context->getFirstLevelNodeCache()->flush(); $this->emitNodeUpdated($this); }
/** * @test */ public function removePropertyDoesNotTouchAContentObject() { $this->inject($this->nodeData, 'persistenceManager', $this->createMock(PersistenceManagerInterface::class)); $className = uniqid('Test'); eval('class ' . $className . ' { public $title = "My Title"; }'); $contentObject = new $className(); $this->nodeData->setContentObject($contentObject); $this->nodeData->removeProperty('title'); $this->assertTrue($this->nodeData->hasProperty('title')); $this->assertEquals('My Title', $this->nodeData->getProperty('title')); }
/** * 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); }
/** * Remove the property from the given node. * * @param NodeData $node * @return void */ public function execute(NodeData $node) { $node->removeProperty($this->propertyName); }