本文整理汇总了PHP中TYPO3\TYPO3CR\Domain\Service\NodeTypeManager::getNodeType方法的典型用法代码示例。如果您正苦于以下问题:PHP NodeTypeManager::getNodeType方法的具体用法?PHP NodeTypeManager::getNodeType怎么用?PHP NodeTypeManager::getNodeType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\TYPO3CR\Domain\Service\NodeTypeManager
的用法示例。
在下文中一共展示了NodeTypeManager::getNodeType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: searchForNodeAction
/**
* @param string $searchWord
* @param Site $selectedSite
* @return void
*/
public function searchForNodeAction($searchWord, Site $selectedSite = NULL)
{
$documentNodeTypes = $this->nodeTypeManager->getSubNodeTypes('TYPO3.Neos:Document');
$shortcutNodeType = $this->nodeTypeManager->getNodeType('TYPO3.Neos:Shortcut');
$nodeTypes = array_diff($documentNodeTypes, array($shortcutNodeType));
$sites = array();
$activeSites = $this->siteRepository->findOnline();
foreach ($selectedSite ? array($selectedSite) : $activeSites as $site) {
/** @var Site $site */
$contextProperties = array('workspaceName' => 'live', 'currentSite' => $site);
$contentDimensionPresets = $this->contentDimensionPresetSource->getAllPresets();
if (count($contentDimensionPresets) > 0) {
$mergedContentDimensions = array();
foreach ($contentDimensionPresets as $contentDimensionIdentifier => $contentDimension) {
$mergedContentDimensions[$contentDimensionIdentifier] = array($contentDimension['default']);
foreach ($contentDimension['presets'] as $contentDimensionPreset) {
$mergedContentDimensions[$contentDimensionIdentifier] = array_merge($mergedContentDimensions[$contentDimensionIdentifier], $contentDimensionPreset['values']);
}
$mergedContentDimensions[$contentDimensionIdentifier] = array_values(array_unique($mergedContentDimensions[$contentDimensionIdentifier]));
}
$contextProperties['dimensions'] = $mergedContentDimensions;
}
/** @var ContentContext $liveContext */
$liveContext = $this->contextFactory->create($contextProperties);
$firstActiveDomain = $site->getFirstActiveDomain();
$nodes = $this->nodeSearchService->findByProperties($searchWord, $nodeTypes, $liveContext, $liveContext->getCurrentSiteNode());
if (count($nodes) > 0) {
$sites[$site->getNodeName()] = array('site' => $site, 'domain' => $firstActiveDomain ? $firstActiveDomain->getHostPattern() : $this->request->getHttpRequest()->getUri()->getHost(), 'nodes' => $nodes);
}
}
$this->view->assignMultiple(array('searchWord' => $searchWord, 'protocol' => $this->request->getHttpRequest()->getUri()->getScheme(), 'selectedSite' => $selectedSite, 'sites' => $sites, 'activeSites' => $activeSites));
}
示例2: create
/**
* Helper method for creating a new node.
*
* @param NodeInterface $referenceNode
* @param array $nodeData
* @param string $position
* @return NodeInterface
* @throws \InvalidArgumentException
*/
public function create(NodeInterface $referenceNode, array $nodeData, $position)
{
if (!in_array($position, array('before', 'into', 'after'), true)) {
throw new \InvalidArgumentException('The position should be one of the following: "before", "into", "after".', 1347133640);
}
$nodeType = $this->nodeTypeManager->getNodeType($nodeData['nodeType']);
if ($nodeType->isOfType('TYPO3.Neos:Document') && !isset($nodeData['properties']['uriPathSegment']) && isset($nodeData['properties']['title'])) {
$nodeData['properties']['uriPathSegment'] = Utility::renderValidNodeName($nodeData['properties']['title']);
}
$proposedNodeName = isset($nodeData['nodeName']) ? $nodeData['nodeName'] : null;
$nodeData['nodeName'] = $this->nodeService->generateUniqueNodeName($this->getDesignatedParentNode($referenceNode, $position)->getPath(), $proposedNodeName);
if ($position === 'into') {
$newNode = $referenceNode->createNode($nodeData['nodeName'], $nodeType);
} else {
$parentNode = $referenceNode->getParent();
$newNode = $parentNode->createNode($nodeData['nodeName'], $nodeType);
if ($position === 'before') {
$newNode->moveBefore($referenceNode);
} else {
$newNode->moveAfter($referenceNode);
}
}
if (isset($nodeData['properties']) && is_array($nodeData['properties'])) {
foreach ($nodeData['properties'] as $propertyName => $propertyValue) {
$newNode->setProperty($propertyName, $propertyValue);
}
}
return $newNode;
}
示例3: repairCommand
/**
* Repair inconsistent nodes
*
* This command analyzes and repairs the node tree structure and individual nodes
* based on the current node type configuration.
*
* The following checks will be performed:
*
* {pluginDescriptions}
* <b>Examples:</b>
*
* ./flow node:repair
*
* ./flow node:repair --node-type TYPO3.Neos.NodeTypes:Page
*
* @param string $nodeType Node type name, if empty update all declared node types
* @param string $workspace Workspace name, default is 'live'
* @param boolean $dryRun Don't do anything, but report actions
* @param boolean $cleanup If FALSE, cleanup tasks are skipped
* @return void
*/
public function repairCommand($nodeType = null, $workspace = 'live', $dryRun = false, $cleanup = true)
{
$this->pluginConfigurations = self::detectPlugins($this->objectManager);
if ($this->workspaceRepository->countByName($workspace) === 0) {
$this->outputLine('Workspace "%s" does not exist', array($workspace));
exit(1);
}
if ($nodeType !== null) {
if ($this->nodeTypeManager->hasNodeType($nodeType)) {
$nodeType = $this->nodeTypeManager->getNodeType($nodeType);
} else {
$this->outputLine('Node type "%s" does not exist', array($nodeType));
exit(1);
}
}
if ($dryRun) {
$this->outputLine('Dry run, not committing any changes.');
}
foreach ($this->pluginConfigurations as $pluginConfiguration) {
/** @var NodeCommandControllerPluginInterface $plugin */
$plugin = $pluginConfiguration['object'];
$this->outputLine('<b>' . $plugin->getSubCommandShortDescription('repair') . '</b>');
$this->outputLine();
$plugin->invokeSubCommand('repair', $this->output, $nodeType, $workspace, $dryRun, $cleanup);
$this->outputLine();
}
$this->outputLine('Node repair finished.');
}
示例4: setNodeType
/**
* Set the node type
*
* @param string $nodeType
*/
public function setNodeType($nodeType)
{
if (is_string($nodeType)) {
$nodeType = $this->nodeTypeManager->getNodeType($nodeType);
}
if (!$nodeType instanceof NodeType) {
throw new \InvalidArgumentException('nodeType needs to be of type string or NodeType', 1452100970);
}
$this->nodeType = $nodeType;
}
示例5: readNodeTypeConfigurationFillsTypeAndPropertyConfiguration
/**
* @test
*/
public function readNodeTypeConfigurationFillsTypeAndPropertyConfiguration()
{
$this->assertEquals($this->vieSchemaBuilder->_get('superTypeConfiguration'), array());
$this->assertEquals($this->vieSchemaBuilder->_get('types'), array());
$this->assertEquals($this->vieSchemaBuilder->_get('properties'), array());
$this->vieSchemaBuilder->_call('readNodeTypeConfiguration', 'TYPO3.Neos:TextWithImage', $this->nodeTypeManager->getNodeType('TYPO3.Neos:TextWithImage'));
$this->assertEquals(array('typo3:TYPO3.Neos:TextWithImage' => array('typo3:TYPO3.Neos:Text')), $this->vieSchemaBuilder->_get('superTypeConfiguration'));
$this->arrayHasKey('typo3:TYPO3.Neos:TextWithImage', $this->vieSchemaBuilder->_get('types'));
$this->assertEquals(4, count($this->vieSchemaBuilder->_get('properties')));
}
示例6: matches
/**
* Returns TRUE if the given node is of the node type this filter expects.
*
* @param \TYPO3\TYPO3CR\Domain\Model\NodeInterface $node
* @return boolean
*/
public function matches(\TYPO3\TYPO3CR\Domain\Model\NodeInterface $node)
{
if ($this->withSubTypes === TRUE) {
return $this->nodeTypeManager->getNodeType($node->getNodeType())->isOfType($this->nodeTypeName);
} else {
$nodeData = \TYPO3\Flow\Reflection\ObjectAccess::getProperty($node, 'nodeData', TRUE);
$nodeType = \TYPO3\Flow\Reflection\ObjectAccess::getProperty($nodeData, 'nodeType', TRUE);
return $nodeType === $this->nodeTypeName;
}
}
示例7: executeInternal
/**
* Executes this finisher
* @see AbstractFinisher::execute()
*
* @return void
* @throws \TYPO3\Form\Exception\FinisherException
*/
protected function executeInternal()
{
$formValues = $this->finisherContext->getFormValues();
$formNode = $this->formRegistry->getFormNode($this->finisherContext->getFormRuntime()->getIdentifier());
$slug = uniqid('post');
$postNode = $formNode->getParent()->createNode($slug, $this->nodeTypeManager->getNodeType('Lelesys.Plugin.ContactForm:FormPost'));
foreach ($formValues as $propertyName => $value) {
$postNode->setProperty($propertyName, $value);
}
$postNode->setProperty('postDateTime', time());
}
示例8: findNodesByRelatedEntitiesFindsExistingNodeWithMatchingEntityProperty
/**
* @test
*/
public function findNodesByRelatedEntitiesFindsExistingNodeWithMatchingEntityProperty()
{
$rootNode = $this->context->getRootNode();
$newNode = $rootNode->createNode('test', $this->nodeTypeManager->getNodeType('TYPO3.TYPO3CR.Testing:NodeTypeWithEntities'));
$testImage = new Image();
$this->persistenceManager->add($testImage);
$newNode->setProperty('image', $testImage);
$this->persistenceManager->persistAll();
$relationMap = array('TYPO3\\Flow\\Tests\\Functional\\Persistence\\Fixtures\\Image' => array($this->persistenceManager->getIdentifierByObject($testImage)));
$result = $this->nodeDataRepository->findNodesByRelatedEntities($relationMap);
$this->assertCount(1, $result);
}
示例9: 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";
}
}
}
示例10: createAction
/**
* Creates a new blog post node
*
* @return void
*/
public function createAction()
{
/** @var NodeInterface $blogDocumentNode */
$blogDocumentNode = $this->request->getInternalArgument('__documentNode');
if ($blogDocumentNode === NULL) {
return 'Error: The Blog Post Plugin cannot determine the current document node. Please make sure to include this plugin only by inserting it into a page / document.';
}
$contentContext = $blogDocumentNode->getContext();
$nodeTemplate = new NodeTemplate();
$nodeTemplate->setNodeType($this->nodeTypeManager->getNodeType('RobertLemke.Plugin.Blog:Post'));
$nodeTemplate->setProperty('title', 'A new blog post');
$nodeTemplate->setProperty('datePublished', $contentContext->getCurrentDateTime());
$slug = uniqid('post');
$postNode = $blogDocumentNode->createNodeFromTemplate($nodeTemplate, $slug);
$currentlyFirstPostNode = $blogDocumentNode->getPrimaryChildNode();
if ($currentlyFirstPostNode !== NULL) {
// FIXME This currently doesn't work, probably due to some TYPO3CR bug / misconception
$postNode->moveBefore($currentlyFirstPostNode);
}
$mainRequest = $this->request->getMainRequest();
$mainUriBuilder = new UriBuilder();
$mainUriBuilder->setRequest($mainRequest);
$mainUriBuilder->setFormat('html');
$uri = $mainUriBuilder->reset()->setCreateAbsoluteUri(TRUE)->uriFor('show', array('node' => $postNode));
$this->redirectToUri($uri);
}
示例11: importProduct
/**
* importProduct
*
* @param array $product
* @param NodeInterface $startingPointProducts
* @param Context $context
*/
private function importProduct(array $product, NodeInterface $startingPointProducts, Context $context)
{
$nodeTemplate = new NodeTemplate();
$nodeTemplate->setNodeType($this->nodeTypeManager->getNodeType('Egobude.Products:Product'));
$nodeTemplate->setProperty('title', $product['title']);
$nodeTemplate->setProperty('sku', $product['sku']);
$nodeTemplate->setProperty('price', $product['price']);
$similarProducts = $this->getRandomProducts($context, $startingPointProducts);
if (!empty($similarProducts)) {
$nodeTemplate->setProperty('similarProducts', $similarProducts);
}
$accessories = $this->getRandomProducts($context, $startingPointProducts);
if (!empty($accessories)) {
$nodeTemplate->setProperty('accessories', $accessories);
}
$productNode = $startingPointProducts->createNodeFromTemplate($nodeTemplate);
if (!empty($product['description'])) {
$description = $product['description'];
$mainContentNode = $productNode->getNode('main');
$bodyTemplate = new NodeTemplate();
$bodyTemplate->setNodeType($this->nodeTypeManager->getNodeType('TYPO3.Neos.NodeTypes:Text'));
$bodyTemplate->setProperty('text', $description);
$mainContentNode->createNodeFromTemplate($bodyTemplate);
}
}
示例12: importNodeType
/**
* @param string $nodeType
* @param string $referenceNodePath
* @throws Exception
* @return void
*/
public function importNodeType($nodeType, $referenceNodePath = NULL)
{
$referenceNodePath = $referenceNodePath !== NULL ? $referenceNodePath : $this->defaultReferenceNodePath;
if ($referenceNodePath === NULL) {
throw new Exception('Error: Parent node path not found');
}
$contentContext = $this->createContext();
$nodeData = $this->getNodeTypeResource($nodeType);
if ($nodeData !== NULL) {
$referenceNode = $contentContext->getNode($referenceNodePath);
if (!$referenceNode instanceof NodeInterface) {
throw new Exception('Error: referenceNode is not instance of \\TYPO3\\TYPO3CR\\Domain\\Model\\NodeInterface');
}
// Add content into the reference node (mapping...)
$nodeDataXMLElement = $this->getSimpleXMLElementFromXml($this->loadXML($nodeData));
foreach ($nodeDataXMLElement->node as $nodeXMLElement) {
$nodeType = $this->nodeTypeManager->getNodeType((string) $nodeXMLElement->attributes()->type);
$contentNode = $contentContext->getNodeByIdentifier((string) $nodeXMLElement->attributes()->identifier);
if ($contentNode instanceof NodeInterface) {
$this->importNodeProperties($nodeXMLElement, $contentNode);
} else {
$contentNode = $referenceNode->getPrimaryChildNode()->createSingleNode((string) $nodeXMLElement->attributes()->nodeName, $nodeType);
$this->importNodeProperties($nodeXMLElement, $contentNode);
}
}
}
}
示例13: showCommand
/**
* Show node type configuration after applying all supertypes etc
*
* @param string $nodeType the node type to optionally filter for
* @return void
*/
public function showCommand($nodeType = null)
{
if ($nodeType !== null) {
/** @var \TYPO3\TYPO3CR\Domain\Model\NodeType $nodeType */
$nodeType = $this->nodeTypeManager->getNodeType($nodeType);
$configuration = $nodeType->getFullConfiguration();
} else {
$nodeTypes = $this->nodeTypeManager->getNodeTypes();
$configuration = array();
/** @var \TYPO3\TYPO3CR\Domain\Model\NodeType $nodeType */
foreach ($nodeTypes as $nodeTypeName => $nodeType) {
$configuration[$nodeTypeName] = $nodeType->getFullConfiguration();
}
}
$this->output(\Symfony\Component\Yaml\Yaml::dump($configuration, 5, 2));
}
开发者ID:robertlemke,项目名称:Flowpack.ElasticSearch.ContentRepositoryAdaptor,代码行数:22,代码来源:NodeTypeCommandController.php
示例14: inheritanceBasedConstraintsWork
/**
* @test
*/
public function inheritanceBasedConstraintsWork()
{
$testingNodeTypeWithSubnodes = $this->nodeTypeManager->getNodeType('TYPO3.TYPO3CR.Testing:NodeTypeWithSubnodes');
$testingNodeTypeThatInheritsFromDocumentType = $this->nodeTypeManager->getNodeType('TYPO3.TYPO3CR.Testing:Page');
$nodeWithChildNode = $this->rootNode->createNode('node-with-child-node', $testingNodeTypeWithSubnodes);
$nodeWithChildNode->createNode('page', $testingNodeTypeThatInheritsFromDocumentType);
$this->assertCount(2, $nodeWithChildNode->getChildNodes());
}
示例15: getNodeTypeThrowsExceptionIfFinalNodeTypeIsSubclassed
/**
* @test
* @expectedException \TYPO3\TYPO3CR\Exception\NodeTypeIsFinalException
*/
public function getNodeTypeThrowsExceptionIfFinalNodeTypeIsSubclassed()
{
$this->nodeTypeManager = new NodeTypeManager();
$nodeTypesFixture = array('TYPO3.TYPO3CR.Testing:Base' => array('final' => true), 'TYPO3.TYPO3CR.Testing:Sub' => array('superTypes' => array('TYPO3.TYPO3CR.Testing:Base' => true)));
$mockConfigurationManager = $this->getMockBuilder(ConfigurationManager::class)->disableOriginalConstructor()->getMock();
$mockConfigurationManager->expects($this->atLeastOnce())->method('getConfiguration')->with('NodeTypes')->will($this->returnValue($nodeTypesFixture));
$this->inject($this->nodeTypeManager, 'configurationManager', $mockConfigurationManager);
$this->nodeTypeManager->getNodeType('TYPO3.TYPO3CR.Testing:Sub');
}