DmitryDulepov\Realurl\Encoder\UrlEncoder::createUniqueAlias PHP Method

createUniqueAlias() protected method

Creates a unique alias.
protected createUniqueAlias ( array $configuration, $newAliasValue, $idValue ) : string
$configuration array
$newAliasValue
$idValue
return string
    protected function createUniqueAlias(array $configuration, $newAliasValue, $idValue)
    {
        $uniqueAlias = '';
        $counter = 0;
        $maxTry = 100;
        $testNewAliasValue = $newAliasValue;
        while ($counter < $maxTry) {
            // If the test-alias did NOT exist, it must be unique and we break out
            $foundId = $this->getFromAliasCacheByAliasValue($configuration, $testNewAliasValue, TRUE);
            if (!$foundId || $foundId == $idValue) {
                $uniqueAlias = $testNewAliasValue;
                break;
            }
            $counter++;
            $testNewAliasValue = $newAliasValue . '-' . $counter;
        }
        return $uniqueAlias;
    }