private function getUniqueEntityName($entityName, array $entityConfig, array $existingEntityNames)
    {
        // the shortcut config syntax doesn't require to give entities a name
        if (\is_numeric($entityName)) {
            $entityClassParts = \explode('\\', $entityConfig['class']);
            $entityName = \end($entityClassParts);
        }

        $i = 2;
        $uniqueName = $entityName;
        while (\in_array($uniqueName, $existingEntityNames)) {
            $uniqueName = $entityName.($i++);
        }

        $entityName = $uniqueName;

        // make sure that the entity name is valid as a PHP method name
        // (this is required to allow extending the backend with a custom controller)
        if (!$this->isValidMethodName($entityName)) {
            throw new \InvalidArgumentException(\sprintf('The name of the "%s" entity contains invalid characters (allowed: letters, numbers, underscores; the first character cannot be a number).', $entityName));
        }

        return $entityName;
    }
private function getUniqueEntityName($entityName, array $entityConfig, array $existingEntityNames)
    {
        // the shortcut config syntax doesn't require to give entities a name
        if (\is_numeric($entityName)) {
            $entityClassParts = \explode('\\', $entityConfig['class']);
            $entityName = \end($entityClassParts);
        }

        $i = 2;
        $uniqueName = $entityName;
        while (\in_array($uniqueName, $existingEntityNames)) {
            $uniqueName = $entityName.($i++);
        }

        $entityName = $uniqueName;

        // make sure that the entity name is valid as a PHP method name
        // (this is required to allow extending the backend with a custom controller)
        if (!$this->isValidMethodName($entityName)) {
            throw new \InvalidArgumentException(\sprintf('The name of the "%s" entity contains invalid characters (allowed: letters, numbers, underscores; the first character cannot be a number).', $entityName));
        }

        return $entityName;
    }
private function getUniqueEntityName ( $ entityName , array $ entityConfig , array $ existingEntityNames ) { // the shortcut config syntax doesn't require to give entities a name if ( \ is_numeric ( $ entityName ) ) { $ entityClassParts = \ explode ( '\\' , $ entityConfig [ 'class' ] ) ; $ entityName = \ end ( $ entityClassParts ) ; } $ i = 2 ; $ uniqueName = $ entityName ; while ( \ in_array ( $ uniqueName , $ existingEntityNames ) ) { $ uniqueName = $ entityName . ( $ i ++ ) ; } $ entityName = $ uniqueName ; // make sure that the entity name is valid as a PHP method name // (this is required to allow extending the backend with a custom controller) if ( ! $ this -> isValidMethodName ( $ entityName ) ) { throw new \ InvalidArgumentException ( \ sprintf ( 'The name of the "%s" entity contains invalid characters (allowed: letters, numbers, underscores; the first character cannot be a number).' , $ entityName ) ) ; } return $ entityName ; }
The name of the entity is included in the URLs of the backend to define
the entity used to perform the operations. Obviously, the entity name
must be unique to identify entities unequivocally.

This method ensures that the given entity name is unique among all the
previously existing entities passed as the second argument. This is
achieved by iteratively appending a suffix until the entity name is
guaranteed to be unique.

@param string $entityName
@param array  $entityConfig
@param array  $existingEntityNames

@return string The entity name transformed to be unique
The name of the entity is included in the URLs of the backend to define the entity used to perform the operations . Obviously the entity name must be unique to identify entities unequivocally .