src/Utils/UrlKeyUtil.php
/**
     * Make's the passed URL key unique by adding the next number to the end.
     *
     * @param \TechDivision\Import\Subjects\UrlKeyAwareSubjectInterface $subject  The subject to make the URL key unique for
     * @param array                                                     $entity   The entity to make the URL key unique for
     * @param string                                                    $urlKey   The URL key to make unique
     * @param array                                                     $urlPaths The URL paths to make unique
     *
     * @return string The unique URL key
     */
Make's the passed URL key unique by adding the next number to the end.
@param \TechDivision\Import\Subjects\UrlKeyAwareSubjectInterface $subject  The subject to make the URL key unique for
@param array                                                     $entity   The entity to make the URL key unique for
@param string                                                    $urlKey   The URL key to make unique
@param array                                                     $urlPaths The URL paths to make unique

@return string The unique URL key
Make ' s the passed URL key unique by adding the next number to the end . @param \ TechDivision \ Import \ Subjects \ UrlKeyAwareSubjectInterface $subject The subject to make the URL key unique for @param array $entity The entity to make the URL key unique for @param string $urlKey The URL key to make unique @param array $urlPaths The URL paths to make unique @return string The unique URL key
public function makeUnique(UrlKeyAwareSubjectInterface $subject, array $entity, string $urlKey, array $urlPaths = array()) : string
    {
        $i = -1;
        if ($this->urlRewriteEntityType->equals(UrlRewriteEntityType::CATEGORY) && sizeof($urlPaths) > 0) {
            $i = 0;
        }
        for ($i; $i < sizeof($urlPaths); $i++) {
            $proposedUrlKey = $this->doMakeUnique($subject, $entity, $urlKey, isset($urlPaths[$i]) ? $urlPaths[$i] : null);
            if ($urlKey !== $proposedUrlKey) {
                $urlKey = $proposedUrlKey;
                $i = -2;
            }
        }
        return $urlKey;
    }
public function makeUnique ( UrlKeyAwareSubjectInterface $ subject , array $ entity , string $ urlKey , array $ urlPaths = array ( ) ) : string { $ i = - 1 ; if ( $ this -> urlRewriteEntityType -> equals ( UrlRewriteEntityType :: CATEGORY ) && sizeof ( $ urlPaths ) > 0 ) { $ i = 0 ; } for ( $ i ; $ i < sizeof ( $ urlPaths ) ; $ i ++ ) { $ proposedUrlKey = $ this -> doMakeUnique ( $ subject , $ entity , $ urlKey , isset ( $ urlPaths [ $ i ] ) ? $ urlPaths [ $ i ] : null ) ; if ( $ urlKey !== $ proposedUrlKey ) { $ urlKey = $ proposedUrlKey ; $ i = - 2 ; } } return $ urlKey ; }
Make's the passed URL key unique by adding the next number to the end.
Make ' s the passed URL key unique by adding the next number to the end .
// in general, we want to start at -1, because if NO URL paths has been given // e. g. we've a product or a root category, we want to make sure that we've // no URL collisions. // only in case we've a category AND URL paths have been given, we start at 0, // because the we always want to make sure that also the URL path will be taken // into account when we make the URL key unique. // iterate over the passed URL paths // and try to find a unique URL key // try to make the URL key unique for the given URL path // if the URL key is NOT the same as the passed one or with the parent URL path // it can NOT be used, so we've to persist it temporarily and try it again for // all the other URL paths until we found one that works with every URL path // temporarily persist the URL key // reset the counter and restart the // iteration with the first URL path // return the unique URL key