renderValidNodeName() public static method

Transforms a text (for example a node title) into a valid node name by removing invalid characters and transliterating special characters if possible.
public static renderValidNodeName ( string $name ) : string
$name string The possibly invalid node name
return string A valid node name
 /**
  * Checks if the given $nodeType is allowed as a childNode of the given $childNodeName
  * (which must be auto-created in $this NodeType).
  *
  * Only allowed to be called if $childNodeName is auto-created.
  *
  * @param string $childNodeName The name of a configured childNode of this NodeType
  * @param NodeType $nodeType The NodeType to check constraints for.
  * @return boolean TRUE if the $nodeType is allowed as grandchild node, FALSE otherwise.
  * @throws \InvalidArgumentException If the given $childNodeName is not configured to be auto-created in $this.
  */
 public function allowsGrandchildNodeType($childNodeName, NodeType $nodeType)
 {
     $autoCreatedChildNodes = $this->getAutoCreatedChildNodes();
     if (!isset($autoCreatedChildNodes[$childNodeName])) {
         throw new \InvalidArgumentException('The method "allowsGrandchildNodeType" can only be used on auto-created childNodes, given $childNodeName "' . $childNodeName . '" is not auto-created.', 1403858395);
     }
     $constraints = $autoCreatedChildNodes[$childNodeName]->getConfiguration('constraints.nodeTypes') ?: array();
     $childNodeConfiguration = [];
     foreach ($this->getConfiguration('childNodes') as $name => $configuration) {
         $childNodeConfiguration[Utility::renderValidNodeName($name)] = $configuration;
     }
     $childNodeConstraintConfiguration = ObjectAccess::getPropertyPath($childNodeConfiguration, $childNodeName . '.constraints.nodeTypes') ?: array();
     $constraints = Arrays::arrayMergeRecursiveOverrule($constraints, $childNodeConstraintConfiguration);
     return $this->isNodeTypeAllowedByConstraints($nodeType, $constraints);
 }
 /**
  * Parses the given XML element and adds its content to the internal content tree
  *
  * @param \XMLReader $xmlReader The XML Reader with the element to be parsed as its root
  * @return void
  * @throws ImportException
  */
 protected function parseElement(\XMLReader $xmlReader)
 {
     $elementName = $xmlReader->name;
     switch ($elementName) {
         case 'node':
             // update current node identifier
             $this->nodeIdentifierStack[] = $xmlReader->getAttribute('identifier');
             // update current path
             $nodeName = $xmlReader->getAttribute('nodeName');
             if ($nodeName !== '/') {
                 $this->nodeNameStack[] = Utility::renderValidNodeName($nodeName);
             }
             break;
         case 'variant':
             $path = $this->getCurrentPath();
             $parentPath = $this->getParentPath($path);
             $now = new Now();
             $currentNodeIdentifier = $this->nodeIdentifierStack[count($this->nodeIdentifierStack) - 1];
             $this->nodeDataStack[] = array('Persistence_Object_Identifier' => Algorithms::generateUUID(), 'identifier' => $currentNodeIdentifier, 'nodeType' => $xmlReader->getAttribute('nodeType'), 'workspace' => $xmlReader->getAttribute('workspace'), 'sortingIndex' => $xmlReader->getAttribute('sortingIndex'), 'version' => $xmlReader->getAttribute('version'), 'removed' => (bool) $xmlReader->getAttribute('removed'), 'hidden' => (bool) $xmlReader->getAttribute('hidden'), 'hiddenInIndex' => (bool) $xmlReader->getAttribute('hiddenInIndex'), 'path' => $path, 'pathHash' => md5($path), 'parentPath' => $parentPath, 'parentPathHash' => md5($parentPath), 'properties' => array(), 'accessRoles' => array(), 'creationDateTime' => $now, 'lastModificationDateTime' => $now, 'dimensionValues' => array());
             break;
         case 'dimensions':
             $this->nodeDataStack[count($this->nodeDataStack) - 1]['dimensionValues'] = $this->parseDimensionsElement($xmlReader);
             break;
         case 'properties':
             $currentNodeIdentifier = $this->nodeDataStack[count($this->nodeDataStack) - 1]['identifier'];
             $this->nodeDataStack[count($this->nodeDataStack) - 1][$elementName] = $this->parsePropertiesElement($xmlReader, $currentNodeIdentifier);
             break;
         case 'accessRoles':
             $currentNodeIdentifier = $this->nodeDataStack[count($this->nodeDataStack) - 1]['identifier'];
             $this->nodeDataStack[count($this->nodeDataStack) - 1][$elementName] = $this->parseArrayElements($xmlReader, 'accessRoles', $currentNodeIdentifier);
             break;
         case 'hiddenBeforeDateTime':
         case 'hiddenAfterDateTime':
         case 'creationDateTime':
         case 'lastModificationDateTime':
         case 'lastPublicationDateTime':
             $stringValue = trim($xmlReader->readString());
             $dateValue = $this->propertyMapper->convert($stringValue, 'DateTime', $this->propertyMappingConfiguration);
             $this->nodeDataStack[count($this->nodeDataStack) - 1][$elementName] = $dateValue;
             break;
         default:
             throw new ImportException(sprintf('Unexpected element <%s> ', $elementName), 1423578065);
             break;
     }
 }
 /**
  * @test
  * @dataProvider sourcesAndNodeNames
  */
 public function renderValidNodeNameWorks($source, $expectedNodeName)
 {
     $this->assertEquals($expectedNodeName, Utility::renderValidNodeName($source));
 }
 /**
  * Create a workspace
  *
  * @Flow\Validate(argumentName="title", type="\Neos\Flow\Validation\Validator\NotEmptyValidator")
  * @param string $title Human friendly title of the workspace, for example "Christmas Campaign"
  * @param Workspace $baseWorkspace Workspace the new workspace should be based on
  * @param string $visibility Visibility of the new workspace, must be either "internal" or "shared"
  * @param string $description A description explaining the purpose of the new workspace
  * @return void
  */
 public function createAction($title, Workspace $baseWorkspace, $visibility, $description = '')
 {
     $workspace = $this->workspaceRepository->findOneByTitle($title);
     if ($workspace instanceof Workspace) {
         $this->addFlashMessage($this->translator->translateById('workspaces.workspaceWithThisTitleAlreadyExists', [], null, null, 'Modules', 'Neos.Neos'), '', Message::SEVERITY_WARNING);
         $this->redirect('new');
     }
     $workspaceName = Utility::renderValidNodeName($title) . '-' . substr(base_convert(microtime(false), 10, 36), -5, 5);
     while ($this->workspaceRepository->findOneByName($workspaceName) instanceof Workspace) {
         $workspaceName = Utility::renderValidNodeName($title) . '-' . substr(base_convert(microtime(false), 10, 36), -5, 5);
     }
     if ($visibility === 'private') {
         $owner = $this->userService->getCurrentUser();
     } else {
         $owner = null;
     }
     $workspace = new Workspace($workspaceName, $baseWorkspace, $owner);
     $workspace->setTitle($title);
     $workspace->setDescription($description);
     $this->workspaceRepository->add($workspace);
     $this->redirect('index');
 }