本文整理汇总了PHP中TYPO3\TYPO3CR\Domain\Repository\NodeDataRepository::add方法的典型用法代码示例。如果您正苦于以下问题:PHP NodeDataRepository::add方法的具体用法?PHP NodeDataRepository::add怎么用?PHP NodeDataRepository::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\TYPO3CR\Domain\Repository\NodeDataRepository
的用法示例。
在下文中一共展示了NodeDataRepository::add方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initializeObject
/**
* Initializes this workspace.
*
* If this workspace is brand new, a root node is created automatically.
*
* @param integer $initializationCause
* @return void
*/
public function initializeObject($initializationCause)
{
if ($initializationCause === ObjectManagerInterface::INITIALIZATIONCAUSE_CREATED) {
$this->rootNodeData = new NodeData('/', $this);
$this->nodeDataRepository->add($this->rootNodeData);
}
}
示例2: createVariantForContext
/**
* Given a context a new node is returned that is like this node, but
* lives in the new context.
*
* @param \TYPO3\TYPO3CR\Domain\Service\Context $context
* @return NodeInterface
*/
public function createVariantForContext($context)
{
$nodeData = clone $this->nodeData;
$nodeData->adjustToContext($context);
$this->nodeDataRepository->add($nodeData);
$node = $this->nodeFactory->createFromNodeData($nodeData, $context);
$this->context->getFirstLevelNodeCache()->flush();
$this->emitNodeAdded($node);
return $node;
}
示例3: findByParentAndNodeTypeIncludesAddedNodeInRepositoryAndRespectsWorkspaceAndDimensions
/**
* @test
*/
public function findByParentAndNodeTypeIncludesAddedNodeInRepositoryAndRespectsWorkspaceAndDimensions()
{
$liveWorkspace = new Workspace('live');
$nodeData = $this->getMockBuilder('TYPO3\\TYPO3CR\\Domain\\Model\\NodeData')->disableOriginalConstructor()->getMock();
$nodeData->expects($this->any())->method('getIdentifier')->will($this->returnValue('abcd-efgh-ijkl-mnop'));
$nodeData->expects($this->any())->method('getPath')->will($this->returnValue('/foo/bar'));
$nodeData->expects($this->any())->method('getDepth')->will($this->returnValue(2));
$this->nodeDataRepository->add($nodeData);
$dimensions = array('persona' => array('everybody'), 'language' => array('de_DE', 'mul_ZZ'));
$nodeData->expects($this->atLeastOnce())->method('matchesWorkspaceAndDimensions')->with($liveWorkspace, $dimensions)->will($this->returnValue(TRUE));
$this->nodeDataRepository->expects($this->any())->method('getNodeDataForParentAndNodeType')->will($this->returnValue(array()));
$result = $this->nodeDataRepository->findByParentAndNodeType('/foo', NULL, $liveWorkspace, $dimensions);
$this->assertCount(1, $result);
$fetchedNodeData = reset($result);
$this->assertSame($nodeData, $fetchedNodeData);
}
示例4: materializeNodeData
/**
* Materializes the original node data (of a different workspace) into the current
* workspace.
*
* @return void
*/
protected function materializeNodeData()
{
$dimensions = $this->context->getTargetDimensionValues();
$newNodeData = new NodeData($this->nodeData->getPath(), $this->context->getWorkspace(), $this->nodeData->getIdentifier(), $dimensions);
$this->nodeDataRepository->add($newNodeData);
$newNodeData->similarize($this->nodeData);
$this->nodeData = $newNodeData;
$this->nodeDataIsMatchingContext = true;
$nodeType = $this->getNodeType();
foreach ($nodeType->getAutoCreatedChildNodes() as $childNodeName => $childNodeConfiguration) {
$childNode = $this->getNode($childNodeName);
if ($childNode instanceof Node && !$childNode->isNodeDataMatchingContext()) {
$childNode->materializeNodeData();
}
}
}
示例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 characters, numbers and the "-" sign).', 1292428697);
}
$nodeWorkspace = $workspace ?: $this->workspace;
$newPath = $this->path . ($this->path === '/' ? '' : '/') . $name;
if ($this->nodeDataRepository->findOneByPath($newPath, $nodeWorkspace, $dimensions) !== 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);
$this->nodeDataRepository->add($newNodeData);
$this->nodeDataRepository->setNewIndex($newNodeData, NodeDataRepository::POSITION_LAST);
if ($nodeType !== NULL) {
$newNodeData->setNodeType($nodeType);
}
return $newNodeData;
}