Example #1
0
 /**
  * Check wither the routing table has a specific route
  * @param Router $router
  * @return bool
  */
 public function has(Router $router)
 {
     $found = false;
     foreach ($this->_routingTable as $routeID => $routeDetails) {
         if (preg_match("/^" . str_replace('/', '\\/', $routeDetails['_url_']) . "\$/i", $router->getFinalRequestedId()) && in_array($router->getRequest()->getMethod(), $this->_routingTable[$routeID]['_method_'])) {
             $found = true;
             break;
         }
     }
     $router->setController($this->_routingTable[$routeID]['_controller_']);
     $router->setAction($this->_routingTable[$routeID]['_action_']);
     if (!empty($router->getParams())) {
         $index = 0;
         $parameters = array();
         $routerFetchedParameters = $router->getParams();
         foreach ($this->_routingTable[$routeID]['_params_'] as $parameter) {
             $parameters[$parameter] = $routerFetchedParameters[$index++];
         }
         $router->setParams($parameters);
     }
     return $found;
 }
Example #2
0
 public static function transfer(Router $router, $where, $data = false)
 {
     $route = new static(false, false, $where);
     $router->setController($route->getController());
     $router->setAction($route->getAction());
     if (is_array($data)) {
         $router->setData($data);
     }
     return $router->handle();
 }