/** * @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)); }
/** * 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; }
/** * 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.'); }
/** * 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; }
/** * @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'))); }
/** * 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; } }
/** * 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()); }
/** * @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); }
/** * 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"; } } }
/** * 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); }
/** * 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); } }
/** * @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); } } } }
/** * 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)); }
/** * @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()); }
/** * @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'); }
/** * Render the label for the given $nodeTypeName * * @param string $nodeTypeName * @throws \TYPO3\TYPO3CR\Exception\NodeTypeNotFoundException * @return string */ public function labelForNodeType($nodeTypeName) { if (!$this->nodeTypeManager->hasNodeType($nodeTypeName)) { $explodedNodeTypeName = explode(':', $nodeTypeName); return end($explodedNodeTypeName); } $nodeType = $this->nodeTypeManager->getNodeType($nodeTypeName); return $nodeType->getLabel(); }
/** * Gets a storage folder by type, and creates it if needed * * @param string $nodeTypeName * @param NodeInterface $rootNode * @return NodeInterface */ protected function getStorageFolder($nodeTypeName, NodeInterface $rootNode) { $query = new FlowQuery([$rootNode]); $storageFolder = $query->find('[instanceof ' . $nodeTypeName . ']')->get(0); if (!$storageFolder instanceof NodeInterface) { $storageFolder = $rootNode->createNode(uniqid('node-'), $this->nodeTypeManager->getNodeType($nodeTypeName)); } return $storageFolder; }
/** * @param Context $context * @return NodeInterface * @throws NodeTypeNotFoundException * @throws NodeConfigurationException */ public function findOrCreateMetaDataRootNode(Context $context) { if ($this->metaDataRootNode instanceof NodeInterface) { return $this->metaDataRootNode; } $metaDataRootNodeData = $this->metaDataRepository->findOneByPath('/' . MetaDataRepository::METADATA_ROOT_NODE_NAME, $context->getWorkspace()); if ($metaDataRootNodeData !== null) { $metaDataRootNode = $this->nodeFactory->createFromNodeData($metaDataRootNodeData, $context); return $metaDataRootNode; } $nodeTemplate = new NodeTemplate(); $nodeTemplate->setNodeType($this->nodeTypeManager->getNodeType('unstructured')); $nodeTemplate->setName(MetaDataRepository::METADATA_ROOT_NODE_NAME); $context = $this->contextFactory->create(['workspaceName' => 'live']); $rootNode = $context->getRootNode(); $this->metaDataRootNode = $rootNode->createNodeFromTemplate($nodeTemplate); $this->persistenceManager->persistAll(); return $this->metaDataRootNode; }
/** * @test */ public function getChildNodesWithNodeTypeFilterWorks() { $documentNodeType = $this->nodeTypeManager->getNodeType('TYPO3.TYPO3CR.Testing:Document'); $headlineNodeType = $this->nodeTypeManager->getNodeType('TYPO3.TYPO3CR.Testing:Headline'); $imageNodeType = $this->nodeTypeManager->getNodeType('TYPO3.TYPO3CR.Testing:Image'); $node = $this->context->getRootNode()->createNode('node-with-child-node', $documentNodeType); $node->createNode('headline', $headlineNodeType); $node->createNode('text', $imageNodeType); $this->assertCount(1, $node->getChildNodes('TYPO3.TYPO3CR.Testing:Headline')); }
/** * @throws \TYPO3\TYPO3CR\Exception\NodeTypeNotFoundException */ protected function createNodesForNodeSearchTest() { $rootNode = $this->context->getRootNode(); $newNode1 = $rootNode->createNode('test-node-1', $this->nodeTypeManager->getNodeType('TYPO3.TYPO3CR.Testing:NodeType')); $newNode1->setProperty('test1', 'simpleTestValue'); $newNode2 = $rootNode->createNode('test-node-2', $this->nodeTypeManager->getNodeType('TYPO3.TYPO3CR.Testing:NodeType')); $newNode2->setProperty('test2', 'simpleTestValue'); $newNode2 = $rootNode->createNode('test-node-3', $this->nodeTypeManager->getNodeType('TYPO3.TYPO3CR.Testing:NodeType')); $newNode2->setProperty('test1', 'otherValue'); $this->persistenceManager->persistAll(); }
/** * @param NodeInterface $documentNode */ protected function createBatchContentNodes(NodeInterface $documentNode) { $mainContentCollection = $documentNode->getNode('main'); for ($j = 0; $j < $this->preset->getContentNodeByDocument(); $j++) { try { $nodeType = $this->nodeTypeManager->getNodeType($this->preset->getContentNodeType()); $generator = $this->getNodeGeneratorImplementationClassByNodeType($nodeType); $generator->create($mainContentCollection, $nodeType); } catch (NodeExistsException $e) { } } }
/** * Creates some sample nodes to run tests against */ protected function createNodesForNodeSearchTest() { $rootNode = $this->context->getRootNode(); $newNode1 = $rootNode->createNode('test-node-1', $this->nodeTypeManager->getNodeType('TYPO3.Neos.NodeTypes:Page')); $newNode1->setProperty('title', 'chicken'); $newNode2 = $rootNode->createNode('test-node-2', $this->nodeTypeManager->getNodeType('TYPO3.Neos.NodeTypes:Page')); $newNode2->setProperty('title', 'chicken'); $newNode2 = $rootNode->createNode('test-node-3', $this->nodeTypeManager->getNodeType('TYPO3.Neos.NodeTypes:Page')); $newNode2->setProperty('title', 'egg'); $this->persistenceManager->persistAll(); $this->nodeIndexCommandController->buildCommand(); }
/** * Detects and retrieves the NodeType of the given $nodeXml * * @param \SimpleXMLElement $nodeXml * @return NodeType * @throws \TYPO3\Neos\Domain\Exception */ protected function parseNodeType(\SimpleXMLElement $nodeXml) { $nodeTypeName = (string) $nodeXml['type']; if ($this->nodeTypeManager->hasNodeType($nodeTypeName)) { $nodeType = $this->nodeTypeManager->getNodeType($nodeTypeName); if ($nodeType->isAbstract()) { throw new DomainException(sprintf('The node type "%s" is marked as abstract and cannot be assigned to nodes.', $nodeTypeName), 1386590052); } return $nodeType; } return $this->nodeTypeManager->createNodeType($nodeTypeName); }
/** * @test */ public function aSingleNodeExportedWithNodeDataExportCanBeImportedWithNodeDataImport() { $originalNode = $this->rootNode->createNode('foo', $this->nodeTypeManager->getNodeType('TYPO3.TYPO3CR.Testing:ImportExport')); $originalNode->setProperty('description', 'Some node with a property'); $originalNode->setProperty('someDate', new \DateTime()); $this->persistenceManager->persistAll(); $exportService = new NodeExportService(); $xml = $exportService->export('/')->outputMemory(); $this->nodeDataRepository->removeAll(); $this->workspaceRepository->removeAll(); $this->saveNodesAndTearDownRootNodeAndRepository(); $this->setUpRootNodeAndRepository(); $importService = new NodeImportService(); $reader = new \XMLReader(); $reader->XML($xml); $importService->import($reader, '/'); $importedNode = $this->rootNode->getNode('foo'); $this->assertNotNull($importedNode, 'Expected node not found'); $this->assertSame($originalNode->getIdentifier(), $importedNode->getIdentifier()); $this->assertSame($originalNode->getProperty('description'), $importedNode->getProperty('description')); $this->assertEquals($originalNode->getProperty('someDate'), $importedNode->getProperty('someDate')); }
/** * Return an array with child nodes which should be automatically created * * @return array the key of this array is the name of the child, and the value its NodeType. * @api */ public function getAutoCreatedChildNodes() { $this->initialize(); if (!isset($this->fullConfiguration['childNodes'])) { return array(); } $autoCreatedChildNodes = array(); foreach ($this->fullConfiguration['childNodes'] as $childNodeName => $childNodeConfiguration) { if (isset($childNodeConfiguration['type'])) { $autoCreatedChildNodes[Utility::renderValidNodeName($childNodeName)] = $this->nodeTypeManager->getNodeType($childNodeConfiguration['type']); } } return $autoCreatedChildNodes; }
/** * @param Asset $asset * @param MetaDataCollection $metaDataCollection * @throws NodeTypeNotFoundException * @throws \TYPO3\Flow\Persistence\Exception\IllegalObjectTypeException * @return void */ public function mapMetaData(Asset $asset, MetaDataCollection $metaDataCollection) { $nodeType = $this->nodeTypeManager->getNodeType('Neos.MetaData:Image'); $asset = $metaDataCollection->get('asset'); $assetNodeData = $this->metaDataRepository->findOneByAssetIdentifier($asset->getIdentifier(), $this->context->getWorkspace()); if ($assetNodeData === null) { $assetNodeDataTemplate = $this->createAssetNodeTemplate($asset, $nodeType); $this->mapMetaDataToNodeData($assetNodeDataTemplate, $nodeType, $metaDataCollection); $this->nodeService->findOrCreateMetaDataRootNode($this->context)->createNodeFromTemplate($assetNodeDataTemplate); } else { $this->mapMetaDataToNodeData($assetNodeData, $nodeType, $metaDataCollection); $this->metaDataRepository->update($assetNodeData); } }
/** * @test */ public function nodesCanHaveCustomImplementationClass() { $rootNode = $this->context->getRootNode(); $testingNodeType = $this->nodeTypeManager->getNodeType('TYPO3.TYPO3CR.Testing:NodeTypeWithReferences'); $happyNodeType = $this->nodeTypeManager->getNodeType('TYPO3.TYPO3CR.Testing:HappyTestingNode'); $headlineNodeType = $this->nodeTypeManager->getNodeType('TYPO3.TYPO3CR.Testing:Headline'); $fooNode = $rootNode->createNode('foo', $testingNodeType); $happyNode = $fooNode->createNode('bar', $happyNodeType); $bazNode = $happyNode->createNode('baz', $headlineNodeType); $this->assertNotInstanceOf('\\TYPO3\\TYPO3CR\\Tests\\Functional\\Domain\\Fixtures\\HappyNode', $fooNode); $this->assertInstanceOf('\\TYPO3\\TYPO3CR\\Tests\\Functional\\Domain\\Fixtures\\HappyNode', $happyNode); $this->assertNotInstanceOf('\\TYPO3\\TYPO3CR\\Tests\\Functional\\Domain\\Fixtures\\HappyNode', $bazNode); $this->assertEquals('bar claps hands!', $happyNode->clapsHands()); }
/** * Detects the requested node type and returns a corresponding NodeType instance. * * @param string $targetType * @param array $source * @return \TYPO3\TYPO3CR\Domain\Model\NodeType */ protected function extractNodeType($targetType, array $source) { if (isset($source['__nodeType'])) { $nodeTypeName = $source['__nodeType']; } else { $matches = array(); preg_match(self::EXTRACT_CONTENT_TYPE_PATTERN, $targetType, $matches); if (isset($matches['nodeType'])) { $nodeTypeName = $matches['nodeType']; } else { $nodeTypeName = 'unstructured'; } } return $this->nodeTypeManager->getNodeType($nodeTypeName); }
/** * Creates some sample nodes to run tests against */ protected function createNodesForNodeSearchTest() { $rootNode = $this->context->getRootNode(); $newNode1 = $rootNode->createNode('test-node-1', $this->nodeTypeManager->getNodeType('TYPO3.Neos.NodeTypes:Page')); $newNode1->setProperty('title', 'chicken'); $newNode2 = $rootNode->createNode('test-node-2', $this->nodeTypeManager->getNodeType('TYPO3.Neos.NodeTypes:Page')); $newNode2->setProperty('title', 'chicken'); $newNode3 = $rootNode->createNode('test-node-3', $this->nodeTypeManager->getNodeType('TYPO3.Neos.NodeTypes:Page')); $newNode3->setProperty('title', 'egg'); $dimensionContext = $this->contextFactory->create(array('workspaceName' => 'live', 'dimensions' => array('language' => array('de')))); $translatedNode3 = $dimensionContext->adoptNode($newNode3, TRUE); $translatedNode3->setProperty('title', 'Ei'); $this->persistenceManager->persistAll(); $this->nodeIndexCommandController->buildCommand(); }
/** * Reorder child nodes for the given node type * * @param NodeType $nodeType * @param string $workspaceName * @param boolean $dryRun * @return void */ protected function reorderChildNodesByNodeType(NodeType $nodeType, $workspaceName, $dryRun) { $nodeTypes = $this->nodeTypeManager->getSubNodeTypes($nodeType->getName(), false); $nodeTypes[$nodeType->getName()] = $nodeType; if ($this->nodeTypeManager->hasNodeType((string) $nodeType)) { $nodeType = $this->nodeTypeManager->getNodeType((string) $nodeType); $nodeTypeNames[$nodeType->getName()] = $nodeType; } else { $this->output->outputLine('Node type "%s" does not exist', array((string) $nodeType)); exit(1); } /** @var $nodeType NodeType */ foreach ($nodeTypes as $nodeTypeName => $nodeType) { $childNodes = $nodeType->getAutoCreatedChildNodes(); if ($childNodes === array()) { continue; } foreach ($this->getNodeDataByNodeTypeAndWorkspace($nodeTypeName, $workspaceName) as $nodeData) { /** @var NodeInterface $childNodeBefore */ $childNodeBefore = null; $context = $this->nodeFactory->createContextMatchingNodeData($nodeData); $node = $this->nodeFactory->createFromNodeData($nodeData, $context); if (!$node instanceof NodeInterface) { continue; } foreach ($childNodes as $childNodeName => $childNodeType) { $childNode = $node->getNode($childNodeName); if ($childNode) { if ($childNodeBefore) { if ($dryRun === false) { if ($childNodeBefore->getIndex() >= $childNode->getIndex()) { $childNode->moveAfter($childNodeBefore); $this->output->outputLine('Moved node named "%s" after node named "%s" in "%s"', array($childNodeName, $childNodeBefore->getName(), $node->getPath())); } } else { $this->output->outputLine('Should move node named "%s" after node named "%s" in "%s"', array($childNodeName, $childNodeBefore->getName(), $node->getPath())); } } } else { $this->output->outputLine('Missing child node named "%s" in "%s".', array($childNodeName, $node->getPath())); } $childNodeBefore = $childNode; } } } }