Example #1
0
 public function getMatch(Request $request)
 {
     $path = $request->getPath();
     $matches = [];
     $data = ['route' => '/', 'matches' => []];
     foreach ($this->_routes as $rule => $route) {
         if (isset($this->_paths[$path])) {
             $data = $this->_paths[$path];
             break;
         }
         $regex = "/<(.+?):(.+?)>/";
         $rule = preg_replace($regex, '(?P<\\1>\\2)', $rule);
         $regex = addcslashes($rule, '/');
         if (preg_match("/{$regex}/", $path, $matches)) {
             $data = ['matches' => $matches, 'route' => $route];
             $this->_paths[$path] = $data;
             break;
         }
     }
     return $data;
 }