public function generate($pattern, array $options = array())
    {
        $options += array(
            'translit' => true,
            'language' => null,
            'placeholders' => array()
        );

        $result = null;
        $this->hook->attach('alias.generate.before', $pattern, $options, $result);

        if (isset($result)) {
            return (string) $result;
        }

        $alias = $pattern;
        if (!empty($options['placeholders'])) {
            $alias = gplcart_string_replace($pattern, $options['placeholders'], $options);
        }

        if (!empty($options['translit'])) {
            $alias = gplcart_string_slug($this->language->translit($alias, $options['language']));
        }

        $trimmed = mb_strimwidth(str_replace(' ', '-', trim($alias)), 0, 100, '');
        $result = $this->getUnique($trimmed);
        $this->hook->attach('alias.generate.after', $pattern, $options, $result);
        return $result;
    }
public function generate($pattern, array $options = array())
    {
        $options += array(
            'translit' => true,
            'language' => null,
            'placeholders' => array()
        );

        $result = null;
        $this->hook->attach('alias.generate.before', $pattern, $options, $result);

        if (isset($result)) {
            return (string) $result;
        }

        $alias = $pattern;
        if (!empty($options['placeholders'])) {
            $alias = gplcart_string_replace($pattern, $options['placeholders'], $options);
        }

        if (!empty($options['translit'])) {
            $alias = gplcart_string_slug($this->language->translit($alias, $options['language']));
        }

        $trimmed = mb_strimwidth(str_replace(' ', '-', trim($alias)), 0, 100, '');
        $result = $this->getUnique($trimmed);
        $this->hook->attach('alias.generate.after', $pattern, $options, $result);
        return $result;
    }
public function generate ( $ pattern , array $ options = array ( ) ) { $ options += array ( 'translit' => true , 'language' => null , 'placeholders' => array ( ) ) ; $ result = null ; $ this -> hook -> attach ( 'alias.generate.before' , $ pattern , $ options , $ result ) ; if ( isset ( $ result ) ) { return ( string ) $ result ; } $ alias = $ pattern ; if ( ! empty ( $ options [ 'placeholders' ] ) ) { $ alias = gplcart_string_replace ( $ pattern , $ options [ 'placeholders' ] , $ options ) ; } if ( ! empty ( $ options [ 'translit' ] ) ) { $ alias = gplcart_string_slug ( $ this -> language -> translit ( $ alias , $ options [ 'language' ] ) ) ; } $ trimmed = mb_strimwidth ( str_replace ( ' ' , '-' , trim ( $ alias ) ) , 0 , 100 , '' ) ; $ result = $ this -> getUnique ( $ trimmed ) ; $ this -> hook -> attach ( 'alias.generate.after' , $ pattern , $ options , $ result ) ; return $ result ; }
Generate a URL alias using a pattern and an array of data
@param string $pattern
@param array $options
@return string
Generate a URL alias using a pattern and an array of data