Exemple #1
0
 /**
  * Generate route from text.
  *
  * @param string $text
  * @param bool $withSlash
  *
  * @return string
  */
 public function generateRouteFromText($text, $withSlash = false)
 {
     if ($withSlash) {
         $result = '';
         foreach (explode('/', $text) as $value) {
             if ('' !== ($value = trim($value))) {
                 $result .= '/' . Urlizer::urlize($value);
             }
         }
         return $result ?: '/';
     }
     return $this->normalizeRoute(Urlizer::urlize($text));
 }
 /**
  * Normalize route pattern.
  *
  * @param string $pattern
  *
  * @return string
  */
 public function normalizeRoutePattern($pattern)
 {
     $data = explode('/', $pattern);
     $result = '';
     foreach ($data as $string) {
         if (trim($string)) {
             $result .= '/' . Urlizer::urlize($string);
         }
     }
     return $result;
 }