本文整理汇总了PHP中TYPO3\TYPO3CR\Domain\Model\NodeData::setNodeType方法的典型用法代码示例。如果您正苦于以下问题:PHP NodeData::setNodeType方法的具体用法?PHP NodeData::setNodeType怎么用?PHP NodeData::setNodeType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\TYPO3CR\Domain\Model\NodeData
的用法示例。
在下文中一共展示了NodeData::setNodeType方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setNodeType
/**
* Sets the node type of this node.
*
* @param \TYPO3\TYPO3CR\Domain\Model\NodeType $nodeType
* @return void
* @api
*/
public function setNodeType(NodeType $nodeType)
{
if (!$this->isNodeDataMatchingContext()) {
$this->materializeNodeData();
}
$this->nodeData->setNodeType($nodeType);
$this->context->getFirstLevelNodeCache()->flush();
$this->emitNodeUpdated($this);
}
示例2: theNodeTypeCanBeSetAndRetrieved
/**
* @test
*/
public function theNodeTypeCanBeSetAndRetrieved()
{
$nodeTypeManager = $this->getMock('TYPO3\\TYPO3CR\\Domain\\Service\\NodeTypeManager');
$nodeTypeManager->expects($this->any())->method('getNodeType')->will($this->returnCallback(function ($name) {
return new NodeType($name, array(), array());
}));
$this->nodeData->_set('nodeTypeManager', $nodeTypeManager);
$this->assertEquals('unstructured', $this->nodeData->getNodeType()->getName());
$myNodeType = $nodeTypeManager->getNodeType('typo3:mycontent');
$this->nodeData->setNodeType($myNodeType);
$this->assertEquals($myNodeType, $this->nodeData->getNodeType());
}
示例3: theNodeTypeCanBeSetAndRetrieved
/**
* @test
*/
public function theNodeTypeCanBeSetAndRetrieved()
{
/** @var NodeTypeManager|\PHPUnit_Framework_MockObject_MockObject $mockNodeTypeManager */
$mockNodeTypeManager = $this->getMockBuilder('TYPO3\\TYPO3CR\\Domain\\Service\\NodeTypeManager')->disableOriginalConstructor()->getMock();
$mockNodeTypeManager->expects($this->any())->method('hasNodeType')->will($this->returnValue(true));
$mockNodeTypeManager->expects($this->any())->method('getNodeType')->will($this->returnCallback(function ($name) {
return new NodeType($name, array(), array());
}));
$this->inject($this->nodeData, 'nodeTypeManager', $mockNodeTypeManager);
$this->assertEquals('unstructured', $this->nodeData->getNodeType()->getName());
$myNodeType = $mockNodeTypeManager->getNodeType('typo3:mycontent');
$this->nodeData->setNodeType($myNodeType);
$this->assertEquals($myNodeType, $this->nodeData->getNodeType());
}
示例4: execute
/**
* 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";
}
}
}
示例5: createSingleNodeData
/**
* Creates, adds and returns a child node of this node, without setting default
* properties or creating subnodes.
*
* @param string $name Name of the new node
* @param \TYPO3\TYPO3CR\Domain\Model\NodeType $nodeType Node type of the new node (optional)
* @param string $identifier The identifier of the node, unique within the workspace, optional(!)
* @param \TYPO3\TYPO3CR\Domain\Model\Workspace $workspace
* @param array $dimensions An array of dimension name to dimension values
* @throws NodeExistsException if a node with this path already exists.
* @throws \InvalidArgumentException if the node name is not accepted.
* @return \TYPO3\TYPO3CR\Domain\Model\NodeData
*/
public function createSingleNodeData($name, NodeType $nodeType = null, $identifier = null, Workspace $workspace = null, array $dimensions = null)
{
if (!is_string($name) || preg_match(NodeInterface::MATCH_PATTERN_NAME, $name) !== 1) {
throw new \InvalidArgumentException('Invalid node name "' . $name . '" (a node name must only contain lowercase characters, numbers and the "-" sign).', 1292428697);
}
$nodeWorkspace = $workspace ?: $this->workspace;
$newPath = NodePaths::addNodePathSegment($this->path, $name);
if ($this->nodeDataRepository->findOneByPath($newPath, $nodeWorkspace, $dimensions, null) !== null) {
throw new NodeExistsException(sprintf('Node with path "' . $newPath . '" already exists in workspace %s and given dimensions %s.', $nodeWorkspace->getName(), var_export($dimensions, true)), 1292503471);
}
$newNodeData = new NodeData($newPath, $nodeWorkspace, $identifier, $dimensions);
if ($nodeType !== null) {
$newNodeData->setNodeType($nodeType);
}
$this->nodeDataRepository->setNewIndex($newNodeData, NodeDataRepository::POSITION_LAST);
return $newNodeData;
}
示例6: execute
/**
* Change the Node Type on the given node.
*
* @param NodeData $node
* @return void
*/
public function execute(NodeData $node)
{
$nodeType = $this->nodeTypeManager->getNodeType($this->newType);
$node->setNodeType($nodeType);
}
示例7: execute
/**
* Change the Node Type on the given node.
*
* @param \TYPO3\TYPO3CR\Domain\Model\NodeData $node
* @return void
*/
public function execute(\TYPO3\TYPO3CR\Domain\Model\NodeData $node)
{
$nodeType = $this->nodeTypeManager->getNodeType($this->newType);
$node->setNodeType($nodeType);
}