public function findOneForSlug($slug)
 {
     $exactRedirection = $this->createQuery('r')->where('r.source = ?', $slug)->fetchRecord();
     if ($exactRedirection) {
         return $exactRedirection;
     }
     $wildCardRedirections = $this->createQuery('r')->select('r.id, r.source')->where('r.source LIKE ?', '%*%')->fetchArray();
     foreach ($wildCardRedirections as $array) {
         if (preg_match(sfGlobToRegex::glob_to_regex($array['source']), $slug)) {
             return $this->find($array['id']);
         }
     }
 }
Example #2
0
 public static function setStrictWildcardSlash($boolean)
 {
     self::$strict_wildcard_slash = $boolean;
 }
Example #3
0
 protected function to_regex($str)
 {
     if ($str[0] == '/' && $str[strlen($str) - 1] == '/') {
         return $str;
     } else {
         return sfGlobToRegex::glob_to_regex($str);
     }
 }
 /**
  * @see sfFinder
  */
 protected function to_regex($str)
 {
     // Regular expression
     if ($str[0] == '/' && $str[strlen($str) - 1] == '/') {
         return $str;
     }
     // Anchor path components using path separator
     if ($str[0] != '/') {
         $str = '/' . $str;
     }
     // Strip start anchor to support matching path suffixes
     return '#' . substr(sfGlobToRegex::glob_to_regex($str), 2);
 }