eZ\Bundle\EzPublishMigrationBundle\Command\LegacyStorage\RegenerateUrlAliasesCommand::combinePaths PHP Method

combinePaths() protected method

Explanation: Custom Location and global URL aliases can generate NOP entries, which can be taken over by the autogenerated aliases. When multiple languages exists for the Location that took over, multiple entries with the same link will exist on the same level. In that case it will not be possible to reliably reconstruct what was the path for the original custom alias. For that reason we combine path data to get all possible path combinations. Note: it could happen that original NOP entry was historized after being taken over by the autogenerated alias. So to be complete this would have to take into account history entries as well, but at the moment we lack API to do that. Proper solution of this problem would be introducing separate database table to store custom/global URL alias data.
See also: https://jira.ez.no/browse/EZP-20777
protected combinePaths ( array $pathData ) : string[]
$pathData array
return string[]
    protected function combinePaths(array $pathData)
    {
        $paths = [];
        $levelData = array_shift($pathData);
        $levelElements = $this->extractPathElements($levelData);
        if (!empty($pathData)) {
            $nextElements = $this->combinePaths($pathData);
            foreach ($levelElements as $element1) {
                foreach ($nextElements as $element2) {
                    $paths[] = $element1 . '/' . $element2;
                }
            }
            return $paths;
        }
        return $levelElements;
    }