Beispiel #1
0
 /**
  * {@inheritdoc}
  */
 public function uniquify(&$alias, $source, $langcode)
 {
     $config = $this->configFactory->get('pathauto.settings');
     if (!$this->isReserved($alias, $source, $langcode)) {
         return;
     }
     // If the alias already exists, generate a new, hopefully unique, variant.
     $maxlength = min($config->get('max_length'), $this->aliasStorageHelper->getAliasSchemaMaxlength());
     $separator = $config->get('separator');
     $original_alias = $alias;
     $i = 0;
     do {
         // Append an incrementing numeric suffix until we find a unique alias.
         $unique_suffix = $separator . $i;
         $alias = Unicode::truncate($original_alias, $maxlength - Unicode::strlen($unique_suffix, TRUE)) . $unique_suffix;
         $i++;
     } while ($this->isReserved($alias, $source, $langcode));
 }