src/Model/Behavior/SlugBehavior.php
protected function _uniqueSlug(Entity $entity, $slug, $separator)
    {
        /** @var string $primaryKey */
        $primaryKey = $this->_table->getPrimaryKey();
        $field = $this->_table->aliasField($this->getConfig('field'));

        $conditions = $this->_conditions($entity, $slug);

        $i = 0;
        $suffix = '';
        $length = $this->getConfig('maxLength');

        while ($this->_table->exists($conditions)) {
            $i++;
            $suffix = $separator . $i;
            if ($length && $length < mb_strlen($slug . $suffix)) {
                $slug = mb_substr($slug, 0, $length - mb_strlen($suffix));
            }
            $conditions[$field] = $slug . $suffix;
        }

        return $slug . $suffix;
    }
protected function _uniqueSlug(Entity $entity, $slug, $separator)
    {
        /** @var string $primaryKey */
        $primaryKey = $this->_table->getPrimaryKey();
        $field = $this->_table->aliasField($this->getConfig('field'));

        $conditions = $this->_conditions($entity, $slug);

        $i = 0;
        $suffix = '';
        $length = $this->getConfig('maxLength');

        while ($this->_table->exists($conditions)) {
            $i++;
            $suffix = $separator . $i;
            if ($length && $length < mb_strlen($slug . $suffix)) {
                $slug = mb_substr($slug, 0, $length - mb_strlen($suffix));
            }
            $conditions[$field] = $slug . $suffix;
        }

        return $slug . $suffix;
    }
protected function _uniqueSlug ( Entity $ entity , $ slug , $ separator ) { /** @var string $primaryKey */ $ primaryKey = $ this -> _table -> getPrimaryKey ( ) ; $ field = $ this -> _table -> aliasField ( $ this -> getConfig ( 'field' ) ) ; $ conditions = $ this -> _conditions ( $ entity , $ slug ) ; $ i = 0 ; $ suffix = '' ; $ length = $ this -> getConfig ( 'maxLength' ) ; while ( $ this -> _table -> exists ( $ conditions ) ) { $ i ++ ; $ suffix = $ separator . $ i ; if ( $ length && $ length < mb_strlen ( $ slug . $ suffix ) ) { $ slug = mb_substr ( $ slug , 0 , $ length - mb_strlen ( $ suffix ) ) ; } $ conditions [ $ field ] = $ slug . $ suffix ; } return $ slug . $ suffix ; }
Returns a unique slug.

@param \Cake\ORM\Entity $entity Entity.
@param string $slug Slug.
@param string $separator Separator.
@return string Unique slug.
Returns a unique slug .