/** * 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; }
/** * 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; }
/** * 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); }
/** * 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(); } } }
/** * 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)); }
/** * 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; }
/** * Reorder child nodes according to the current position configuration of child nodes. * * @param NodeType $nodeType Only for this node type, if specified * @param string $workspaceName Name of the workspace to consider * @param boolean $dryRun Simulate? * @return void */ protected function reorderChildNodes(NodeType $nodeType = null, $workspaceName, $dryRun) { if ($nodeType !== null) { $this->output->outputLine('Checking nodes of type "%s" for child nodes that needs reordering ...', array($nodeType->getName())); $this->reorderChildNodesByNodeType($nodeType, $workspaceName, $dryRun); } else { $this->output->outputLine('Checking for child nodes that needs reordering ...'); foreach ($this->nodeTypeManager->getNodeTypes() as $nodeType) { /** @var NodeType $nodeType */ if ($nodeType->isAbstract()) { continue; } $this->reorderChildNodesByNodeType($nodeType, $workspaceName, $dryRun); } } }
/** * @Then /^I should get the list of all available node types as denied node types for this node from the node authorization service$/ */ public function iShouldGetTheListOfAllAvailableNodeTypesAsDeniedNodeTypesForThisNodeFromTheNodeAuthorizationService() { if ($this->isolated === true) { $this->callStepInSubProcess(__METHOD__); } else { $availableNodeTypes = $this->nodeTypeManager->getNodeTypes(); $deniedNodeTypeNames = $this->nodeAuthorizationService->getNodeTypeNamesDeniedForCreation($this->currentNodes[0]); if (count($availableNodeTypes) !== count($deniedNodeTypeNames)) { Assert::fail('The node authorization service did not return the expected amount of node type names! Got: ' . implode(', ', $deniedNodeTypeNames)); } foreach ($availableNodeTypes as $nodeType) { if (in_array($nodeType, $deniedNodeTypeNames) === false) { Assert::fail('The following node type name has not been returned by the node authorization service: ' . $nodeType); } } } }
/** * Generate the list of allowed sub-node-types per parent-node-type and child-node-name. * * @return array constraints */ protected function generateConstraints() { $constraints = array(); $nodeTypes = $this->nodeTypeManager->getNodeTypes(TRUE); /** @var NodeType $nodeType */ foreach ($nodeTypes as $nodeTypeName => $nodeType) { $constraints[$nodeTypeName] = array('nodeTypes' => array(), 'childNodes' => array()); foreach ($nodeTypes as $innerNodeTypeName => $innerNodeType) { if ($nodeType->allowsChildNodeType($innerNodeType)) { $constraints[$nodeTypeName]['nodeTypes'][$innerNodeTypeName] = TRUE; } } foreach ($nodeType->getAutoCreatedChildNodes() as $key => $_x) { foreach ($nodeTypes as $innerNodeTypeName => $innerNodeType) { if ($nodeType->allowsGrandchildNodeType($key, $innerNodeType)) { $constraints[$nodeTypeName]['childNodes'][$key]['nodeTypes'][$innerNodeTypeName] = TRUE; } } } } return $constraints; }
/** * @test */ public function getNodeTypesWithoutIncludeAbstractContainsNoAbstractNodeTypes() { $nodeTypes = $this->nodeTypeManager->getNodeTypes(false); $this->assertArrayNotHasKey('TYPO3.TYPO3CR.Testing:ContentObject', $nodeTypes); }
/** * Return nodeTypes * * @return mixed */ public function getNodeTypes() { return $this->nodeTypeManager->getNodeTypes(FALSE); }