/** * 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.'); }
/** * Builds a Mapping Collection from the configured node types * * @param \Flowpack\ElasticSearch\Domain\Model\Index $index * @return \Flowpack\ElasticSearch\Mapping\MappingCollection<\Flowpack\ElasticSearch\Domain\Model\Mapping> */ public function buildMappingInformation(Index $index) { $this->lastMappingErrors = new \TYPO3\Flow\Error\Result(); $mappings = new MappingCollection(MappingCollection::TYPE_ENTITY); /** @var NodeType $nodeType */ foreach ($this->nodeTypeManager->getNodeTypes() as $nodeTypeName => $nodeType) { if ($nodeTypeName === 'unstructured' || $nodeType->isAbstract()) { continue; } $type = $index->findType(self::convertNodeTypeNameToMappingName($nodeTypeName)); $mapping = new Mapping($type); // http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-root-object-type.html#_dynamic_templates // 'not_analyzed' is necessary $mapping->addDynamicTemplate('dimensions', array('path_match' => '__dimensionCombinations.*', 'match_mapping_type' => 'string', 'mapping' => array('type' => 'string', 'index' => 'not_analyzed'))); foreach ($nodeType->getProperties() as $propertyName => $propertyConfiguration) { if (isset($propertyConfiguration['search']) && isset($propertyConfiguration['search']['elasticSearchMapping'])) { if (is_array($propertyConfiguration['search']['elasticSearchMapping'])) { $mapping->setPropertyByPath($propertyName, $propertyConfiguration['search']['elasticSearchMapping']); } } elseif (isset($propertyConfiguration['type']) && isset($this->defaultConfigurationPerType[$propertyConfiguration['type']]['elasticSearchMapping'])) { if (is_array($this->defaultConfigurationPerType[$propertyConfiguration['type']]['elasticSearchMapping'])) { $mapping->setPropertyByPath($propertyName, $this->defaultConfigurationPerType[$propertyConfiguration['type']]['elasticSearchMapping']); } } else { $this->lastMappingErrors->addWarning(new \TYPO3\Flow\Error\Warning('Node Type "' . $nodeTypeName . '" - property "' . $propertyName . '": No ElasticSearch Mapping found.')); } } $mappings->add($mapping); } return $mappings; }
/** * 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; }
/** * @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)); }
/** * Returns the node types that the currently authenticated user is *denied* to create within the given $referenceNode * * @param NodeInterface $referenceNode * @return string[] Array of granted node type names */ public function getNodeTypeNamesDeniedForCreation(NodeInterface $referenceNode) { $privilegeSubject = new CreateNodePrivilegeSubject($referenceNode); $allNodeTypes = $this->nodeTypeManager->getNodeTypes(); $deniedCreationNodeTypes = array(); $grantedCreationNodeTypes = array(); $abstainedCreationNodeTypes = array(); foreach ($this->securityContext->getRoles() as $role) { /** @var CreateNodePrivilege $createNodePrivilege */ foreach ($role->getPrivilegesByType(CreateNodePrivilege::class) as $createNodePrivilege) { if (!$createNodePrivilege->matchesSubject($privilegeSubject)) { continue; } $affectedNodeTypes = $createNodePrivilege->getCreationNodeTypes() !== array() ? $createNodePrivilege->getCreationNodeTypes() : $allNodeTypes; if ($createNodePrivilege->isGranted()) { $grantedCreationNodeTypes = array_merge($grantedCreationNodeTypes, $affectedNodeTypes); } elseif ($createNodePrivilege->isDenied()) { $deniedCreationNodeTypes = array_merge($deniedCreationNodeTypes, $affectedNodeTypes); } else { $abstainedCreationNodeTypes = array_merge($abstainedCreationNodeTypes, $affectedNodeTypes); } } } $implicitlyDeniedNodeTypes = array_diff($abstainedCreationNodeTypes, $grantedCreationNodeTypes); return array_merge($implicitlyDeniedNodeTypes, $deniedCreationNodeTypes); }
/** * Converts the nodes types to a fully structured array * in the same structure as the schema to be created. * * The schema also includes abstract node types for the full inheritance information in VIE. * * @return object */ public function generateVieSchema() { if ($this->configuration !== null) { return $this->configuration; } $nodeTypes = $this->nodeTypeManager->getNodeTypes(); foreach ($nodeTypes as $nodeTypeName => $nodeType) { $this->readNodeTypeConfiguration($nodeTypeName, $nodeType); } unset($this->types['typo3:unstructured']); foreach ($this->types as $nodeTypeName => $nodeTypeDefinition) { $this->types[$nodeTypeName]->subtypes = $this->getAllSubtypes($nodeTypeName); $this->types[$nodeTypeName]->ancestors = $this->getAllAncestors($nodeTypeName); $this->removeUndeclaredTypes($this->types[$nodeTypeName]->supertypes); $this->removeUndeclaredTypes($this->types[$nodeTypeName]->ancestors); } foreach ($this->properties as $property => $propertyConfiguration) { if (isset($propertyConfiguration->domains) && is_array($propertyConfiguration->domains)) { foreach ($propertyConfiguration->domains as $domain) { if (preg_match('/TYPO3\\.Neos\\.NodeTypes:.*Column/', $domain)) { $this->properties[$property]->ranges = array_keys($this->types); } } } } // Convert the TYPO3.Neos:ContentCollection element to support content-collection // TODO Move to node type definition if (isset($this->types['typo3:TYPO3.Neos:ContentCollection'])) { $this->addProperty('typo3:TYPO3.Neos:ContentCollection', 'typo3:content-collection', array()); $this->types['typo3:TYPO3.Neos:ContentCollection']->specific_properties[] = 'typo3:content-collection'; $this->properties['typo3:content-collection']->ranges = array_keys($this->types); } $this->configuration = (object) array('types' => (object) $this->types, 'properties' => (object) $this->properties); return $this->configuration; }
/** * 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(); }
/** * 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'))); }
public function setUp() { $this->mockWorkspace = $this->getMock('TYPO3\\TYPO3CR\\Domain\\Model\\Workspace', array(), array(), '', FALSE); $this->mockNodeType = $this->getMock('TYPO3\\TYPO3CR\\Domain\\Model\\NodeType', array(), array(), '', FALSE); $this->mockNodeTypeManager = $this->getMock('TYPO3\\TYPO3CR\\Domain\\Service\\NodeTypeManager', array(), array(), '', FALSE); $this->mockNodeTypeManager->expects($this->any())->method('getNodeType')->will($this->returnValue($this->mockNodeType)); $this->nodeData = $this->getAccessibleMock('TYPO3\\TYPO3CR\\Domain\\Model\\NodeData', array('dummy'), array('/foo/bar', $this->mockWorkspace)); $this->nodeData->_set('nodeTypeManager', $this->mockNodeTypeManager); $this->nodeData->_set('nodeDataRepository', $this->getMock('TYPO3\\Flow\\Persistence\\RepositoryInterface')); }
/** * Called by the Flow object framework after creating the object and resolving all dependencies. * * @param integer $cause Creation cause */ public function initializeObject($cause) { parent::initializeObject($cause); foreach ($this->nodeTypeManager->getNodeTypes() as $nodeType) { $searchSettingsForNodeType = $nodeType->getConfiguration('search'); if (is_array($searchSettingsForNodeType) && isset($searchSettingsForNodeType['fulltext']['isRoot']) && $searchSettingsForNodeType['fulltext']['isRoot'] === TRUE) { $this->fulltextRootNodeTypes[] = $nodeType->getName(); } } }
/** * 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()); }
public function setUp() { $this->mockWorkspace = $this->getMockBuilder(Workspace::class)->disableOriginalConstructor()->getMock(); $this->nodeData = $this->getAccessibleMock(NodeData::class, array('addOrUpdate'), array('/foo/bar', $this->mockWorkspace)); $this->mockNodeType = $this->getMockBuilder(NodeType::class)->disableOriginalConstructor()->getMock(); $this->mockNodeTypeManager = $this->getMockBuilder(NodeTypeManager::class)->disableOriginalConstructor()->getMock(); $this->mockNodeTypeManager->expects($this->any())->method('getNodeType')->will($this->returnValue($this->mockNodeType)); $this->mockNodeTypeManager->expects($this->any())->method('hasNodeType')->will($this->returnValue(true)); $this->inject($this->nodeData, 'nodeTypeManager', $this->mockNodeTypeManager); $this->mockNodeDataRepository = $this->getMockBuilder(NodeDataRepository::class)->disableOriginalConstructor()->getMock(); $this->inject($this->nodeData, 'nodeDataRepository', $this->mockNodeDataRepository); }
/** * @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); }
public function setUp() { $this->mockWorkspace = $this->getMockBuilder('TYPO3\\TYPO3CR\\Domain\\Model\\Workspace')->disableOriginalConstructor()->getMock(); $this->nodeData = $this->getAccessibleMock('TYPO3\\TYPO3CR\\Domain\\Model\\NodeData', array('addOrUpdate'), array('/foo/bar', $this->mockWorkspace)); $this->mockNodeType = $this->getMockBuilder('TYPO3\\TYPO3CR\\Domain\\Model\\NodeType')->disableOriginalConstructor()->getMock(); $this->mockNodeTypeManager = $this->getMockBuilder('TYPO3\\TYPO3CR\\Domain\\Service\\NodeTypeManager')->disableOriginalConstructor()->getMock(); $this->mockNodeTypeManager->expects($this->any())->method('getNodeType')->will($this->returnValue($this->mockNodeType)); $this->mockNodeTypeManager->expects($this->any())->method('hasNodeType')->will($this->returnValue(true)); $this->inject($this->nodeData, 'nodeTypeManager', $this->mockNodeTypeManager); $this->mockNodeDataRepository = $this->getMockBuilder('TYPO3\\TYPO3CR\\Domain\\Repository\\NodeDataRepository')->disableOriginalConstructor()->getMock(); $this->inject($this->nodeData, 'nodeDataRepository', $this->mockNodeDataRepository); }
/** * 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"; } } }
/** * 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 QueryInterface $query * @param $nodeTypeFilter * @return array */ protected function getNodeTypeFilterConstraints(QueryInterface $query, $nodeTypeFilter) { $includeNodeTypeConstraints = array(); $excludeNodeTypeConstraints = array(); $nodeTypeFilterParts = Arrays::trimExplode(',', $nodeTypeFilter); foreach ($nodeTypeFilterParts as $nodeTypeFilterPart) { $nodeTypeFilterPart = trim($nodeTypeFilterPart); if (strpos($nodeTypeFilterPart, '!') === 0) { $negate = true; $nodeTypeFilterPart = substr($nodeTypeFilterPart, 1); } else { $negate = false; } $nodeTypeFilterPartSubTypes = array_merge(array($nodeTypeFilterPart), $this->nodeTypeManager->getSubNodeTypes($nodeTypeFilterPart, false)); foreach ($nodeTypeFilterPartSubTypes as $nodeTypeFilterPartSubType) { if ($negate === true) { $excludeNodeTypeConstraints[] = $query->logicalNot($query->equals('nodeType', $nodeTypeFilterPartSubType)); } else { $includeNodeTypeConstraints[] = $query->equals('nodeType', $nodeTypeFilterPartSubType); } } } $constraints = $excludeNodeTypeConstraints; if (count($includeNodeTypeConstraints) > 0) { $constraints[] = $query->logicalOr($includeNodeTypeConstraints); } return $constraints; }
/** * 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); }
/** * 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)); }
/** * @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); } } } }
/** * Shows a list of nodes * * @param string $searchTerm An optional search term used for filtering the list of nodes * @param string $workspaceName Name of the workspace to search in, "live" by default * @param array $dimensions Optional list of dimensions and their values which should be used for querying * @param array $nodeTypes A list of node types the list should be filtered by * @param NodeInterface $contextNode a node to use as context for the search * @return string */ public function indexAction($searchTerm = '', $workspaceName = 'live', array $dimensions = array(), array $nodeTypes = array('TYPO3.Neos:Document'), NodeInterface $contextNode = null) { $searchableNodeTypeNames = array(); foreach ($nodeTypes as $nodeTypeName) { if (!$this->nodeTypeManager->hasNodeType($nodeTypeName)) { $this->throwStatus(400, sprintf('Unknown node type "%s"', $nodeTypeName)); } $searchableNodeTypeNames[$nodeTypeName] = $nodeTypeName; /** @var NodeType $subNodeType */ foreach ($this->nodeTypeManager->getSubNodeTypes($nodeTypeName, false) as $subNodeTypeName => $subNodeType) { $searchableNodeTypeNames[$subNodeTypeName] = $subNodeTypeName; } } $contentContext = $this->createContentContext($workspaceName, $dimensions); $nodes = $this->nodeSearchService->findByProperties($searchTerm, $searchableNodeTypeNames, $contentContext, $contextNode); $this->view->assign('nodes', $nodes); }
/** * @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()); }
/** * @param NodeInterface $node * @param NodeType $nodeType * @return boolean */ public function isNodeOfType(NodeInterface $node, NodeType $nodeType) { if ($node->getNodeType()->getName() === $nodeType->getName()) { return true; } $subNodeTypes = $this->nodeTypeManager->getSubNodeTypes($nodeType->getName()); return isset($subNodeTypes[$node->getNodeType()->getName()]); }
/** * @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'); }
/** * Generate TypoScript prototype definitions for all node types * * Only fully qualified node types (e.g. MyVendor.MyPackage:NodeType) will be considered. * * @return string */ protected function generateNodeTypeDefinitions() { $code = ''; /** @var NodeType $nodeType */ foreach ($this->nodeTypeManager->getNodeTypes(false) as $nodeType) { $code .= $this->generateTypoScriptForNodeType($nodeType); } return $code; }
/** * This aspect will reset the node type cache after changes to the dynamic node types * * @Flow\After("method(Shel\DynamicNodes\Controller\DynamicNodeTypeController->(update|create|delete|editProperty|createDynamicProperty|updateDynamicProperty|deleteDynamicProperty)Action())") * @param JoinPointInterface $joinPoint The current join point * @return void */ public function clearNodeTypeConfigurationCache(JoinPointInterface $joinPoint) { // Flush note type configuration cache $this->nodeTypeManager->overrideNodeTypes(array()); // Flush configuration version cache to force reload the node type schema $this->cacheManager->getCache('TYPO3_Neos_Configuration_Version')->flush(); // Flush content cache so changed dynamic nodes are updated $this->cacheManager->getCache('TYPO3_TypoScript_Content')->flush(); }
/** * 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; }
/** * Search a page, needed for internal links. * * @deprecated will be removed with 3.0, use Service/NodesController->indexAction() instead * @param string $query * @return void */ public function searchPageAction($query) { $searchResult = array(); $documentNodeTypes = $this->nodeTypeManager->getSubNodeTypes('TYPO3.Neos:Document'); /** @var NodeInterface $node */ foreach ($this->nodeSearchService->findByProperties($query, $documentNodeTypes, $this->createContext('live')) as $node) { $searchResult[$node->getPath()] = $this->processNodeForEditorPlugins($node); } $this->view->assign('value', array('searchResult' => $searchResult, 'success' => true)); }