本文整理汇总了PHP中TYPO3\TYPO3CR\Domain\Service\Context::getNode方法的典型用法代码示例。如果您正苦于以下问题:PHP Context::getNode方法的具体用法?PHP Context::getNode怎么用?PHP Context::getNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\TYPO3CR\Domain\Service\Context
的用法示例。
在下文中一共展示了Context::getNode方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createNodeFromTemplateUsesWorkspacesOfContext
/**
* @test
*/
public function createNodeFromTemplateUsesWorkspacesOfContext()
{
$nodeTemplate = $this->generateBasicNodeTemplate();
$this->context = $this->contextFactory->create(array('workspaceName' => 'user1'));
$rootNode = $this->context->getNode('/');
$node = $rootNode->createNodeFromTemplate($nodeTemplate, 'just-a-node');
$workspace = $node->getWorkspace();
$this->assertEquals('user1', $workspace->getName(), 'Node should be created in workspace of context');
}
示例2: setUpRootNodeAndRepository
/**
* @return void
*/
protected function setUpRootNodeAndRepository()
{
$this->contextFactory = $this->objectManager->get('TYPO3\\TYPO3CR\\Domain\\Service\\ContextFactory');
$this->context = $this->contextFactory->create(array('workspaceName' => 'live'));
$this->nodeDataRepository = $this->objectManager->get('TYPO3\\TYPO3CR\\Domain\\Repository\\NodeDataRepository');
$this->workspaceRepository = $this->objectManager->get('TYPO3\\TYPO3CR\\Domain\\Repository\\WorkspaceRepository');
$this->workspaceRepository->add(new Workspace('live'));
$this->nodeTypeManager = $this->objectManager->get('TYPO3\\TYPO3CR\\Domain\\Service\\NodeTypeManager');
$this->rootNode = $this->context->getNode('/');
$this->persistenceManager->persistAll();
}
示例3: setUpRootNodeAndRepository
/**
* @return void
*/
protected function setUpRootNodeAndRepository()
{
$this->contextFactory = $this->objectManager->get(ContextFactory::class);
$this->context = $this->contextFactory->create(array('workspaceName' => 'live'));
$this->nodeDataRepository = $this->objectManager->get(NodeDataRepository::class);
$this->workspaceRepository = $this->objectManager->get(WorkspaceRepository::class);
$this->workspaceRepository->add(new Workspace('live'));
$this->nodeTypeManager = $this->objectManager->get(NodeTypeManager::class);
$this->rootNode = $this->context->getNode('/');
$this->persistenceManager->persistAll();
}
示例4: getPropertyReturnsReferencedNodesInCorrectWorkspace
/**
* @test
*/
public function getPropertyReturnsReferencedNodesInCorrectWorkspace()
{
$nodeTypeManager = $this->objectManager->get('TYPO3\\TYPO3CR\\Domain\\Service\\NodeTypeManager');
$nodeType = $nodeTypeManager->getNodeType('TYPO3.TYPO3CR.Testing:NodeTypeWithReferences');
$identifier = '81c848ed-abb5-7608-a5db-7eea0331ccfa';
$rootNode = $this->context->getNode('/');
$referencedNode = $rootNode->createNode('referenced-node', $nodeType, $identifier);
$node = $rootNode->createNode('node', $nodeType, '30e893c1-caef-0ca5-b53d-e5699bb8e506');
$node->setProperty('property2', $identifier);
$testContext = $this->contextFactory->create(['workspaceName' => 'test']);
$testRootNode = $testContext->getNode('/');
$testReferencedNode = $testRootNode->createNode('test-referenced-node', $nodeType, $identifier);
$testNode = $testRootNode->getNode('node');
$referencedNodeProperty = $node->getProperty('property2');
$this->assertNotSame($referencedNodeProperty->getWorkspace(), $testReferencedNode->getWorkspace());
$this->assertSame($referencedNodeProperty->getWorkspace(), $referencedNode->getWorkspace());
$testReferencedNodeProperty = $testNode->getProperty('property2');
$this->assertNotSame($testReferencedNodeProperty->getWorkspace(), $referencedNode->getWorkspace());
$this->assertSame($testReferencedNodeProperty->getWorkspace(), $testReferencedNode->getWorkspace());
}
示例5: importCategories
protected function importCategories($parentcategory = 0, $targetPath = '/sites/site')
{
$categoryNodeType = 'Sfi.Kateheo:Category';
$sql = "SELECT * FROM tx_news_domain_model_category\n\t\t\tWHERE parentcategory=:parentcategory AND deleted=0 AND hidden=0\n\t\t\tORDER BY 'sorting'";
$statement = $this->connection->prepare($sql);
$params = array('parentcategory' => $parentcategory);
$statement->execute($params);
foreach ($statement->fetchAll(\PDO::FETCH_ASSOC) as $category) {
$rootNode = $this->context->getNode($targetPath);
$categoryNode = $this->getCategoryByOriginalId($category['uid']);
if ($categoryNode) {
echo "Node " . $category['uid'] . " already exists, skipped\n";
} else {
echo "{$parentcategory} -- {$targetPath}\n";
$categoryNodeTemplate = new \TYPO3\TYPO3CR\Domain\Model\NodeTemplate();
$categoryNodeTemplate->setNodeType($this->nodeTypeManager->getNodeType($categoryNodeType));
$categoryNodeTemplate->setProperty('originalIdentifier', $category['uid']);
$categoryNodeTemplate->setProperty('title', $category['title']);
$categoryNode = $rootNode->createNodeFromTemplate($categoryNodeTemplate);
}
$this->importCategories($category['uid'], $categoryNode->getPath());
}
}
示例6: migrateDown
/**
* Do down migration.
*
* @return void
*/
public function migrateDown()
{
$rootNode = $this->context->getNode('/');
$this->walkNodes($rootNode, MigrationStatus::DIRECTION_DOWN);
}