setBasePath() публичный Метод

Set the base _url - gets prepended to all route _url's.
public setBasePath ( $basePath )
$basePath
Пример #1
0
 public function testMatchRouterUsingBasePath()
 {
     $collection = new RouteCollection();
     $collection->attach(new Route('/users/', array('_controller' => 'PHPRouter\\Test\\SomeController::usersCreate', 'methods' => 'GET')));
     $router = new Router($collection);
     $router->setBasePath('/localhost/webroot');
     foreach ($this->serverProvider() as $server) {
         $_SERVER = $server;
         self::assertTrue((bool) $router->matchCurrentRequest());
     }
 }
Пример #2
0
 public function testMatchRouterUsingBasePath()
 {
     $collection = new RouteCollection();
     $collection->attach(new Route('/users/', array('_controller' => 'PHPRouter\\Test\\SomeController::users_create', 'methods' => 'GET')));
     $router = new Router($collection);
     $router->setBasePath('/localhost/webroot');
     $_SERVER = [];
     $_SERVER['REQUEST_METHOD'] = 'GET';
     $_SERVER['REQUEST_URI'] = '/localhost/webroot/users/';
     $_SERVER['SCRIPT_NAME'] = 'index.php';
     $this->assertTrue((bool) $router->matchCurrentRequest());
 }
Пример #3
0
 /**
  * Create routes by array, and return a Router object
  *
  * @param array $config provide by Config::loadFromFile()
  * @return Router
  */
 public static function parseConfig(array $config)
 {
     $collection = new RouteCollection();
     foreach ($config['routes'] as $name => $route) {
         $collection->attachRoute(new Route($route[0], array('_controller' => str_replace('.', '::', $route[1]), 'methods' => $route[2], 'name' => $name)));
     }
     $router = new Router($collection);
     if (isset($config['base_path'])) {
         $router->setBasePath($config['base_path']);
     }
     return $router;
 }
Пример #4
0
$collection->attachRoute(new Route('/admin/descuentos/setDescuento/', array('_controller' => 'usuariosController::setDescuento', 'methods' => 'POST')));
//-------acceso para administradores para obtener los descuentos------
$collection->attachRoute(new Route('/admin/descuentos/getDescuentos/', array('_controller' => 'usuariosController::getDescuentos', 'methods' => 'POST')));
//-------acceso para administradores para eliminar los descuentos------
$collection->attachRoute(new Route('/admin/descuentos/delDescuento/', array('_controller' => 'usuariosController::delDescuento', 'methods' => 'POST')));
//-------acceso para administradores para actualizar los datos de un descuento------
$collection->attachRoute(new Route('/admin/descuentos/updateDescuento/', array('_controller' => 'usuariosController::updateDescuento', 'methods' => 'POST')));
//-------acceso para imprimir tabla de eventos------
$collection->attachRoute(new Route('/admin/imprimirTablaAdmin/', array('_controller' => 'usuariosController::imprimirTablaAdmin', 'methods' => 'GET')));
//-------Modificacion de datos updatePago------
$collection->attachRoute(new Route('/admin/updatePago/', array('_controller' => 'usuariosController::updatePago', 'methods' => 'POST')));
//-------Modificacion de datos updateMaterial------
$collection->attachRoute(new Route('/admin/updateMaterial/', array('_controller' => 'usuariosController::updateMaterial', 'methods' => 'POST')));
//-------imprimir datos a excel------
$collection->attachRoute(new Route('/admin/reporteExcel/', array('_controller' => 'cReportes::Excel', 'methods' => 'POST')));
//-------obtencion de relacion participantes eventos ------
$collection->attachRoute(new Route('/admin/getRelEventosParticipantes/', array('_controller' => 'usuariosController::getRelEventosParticipantes', 'methods' => 'POST')));
//-------obtencion de relacion participantes en grupo de un evento ------
$collection->attachRoute(new Route('/admin/getRelEventosParticipantesGrupos/', array('_controller' => 'usuariosController::getRelEventosParticipantesGrupos', 'methods' => 'POST')));
$collection->attachRoute(new Route('/admin/fichas/', array('_controller' => 'usuariosController::getAdjuntos', 'methods' => 'POST')));
$collection->attachRoute(new Route('/admin/adjunto/', array('_controller' => 'usuariosController::delAdjuntos', 'methods' => 'POST')));
$collection->attachRoute(new Route('/admin/delComentarios/', array('_controller' => 'usuariosController::delComentarioAdmin', 'methods' => 'POST')));
$collection->attachRoute(new Route('/admin/reporteAccesos/', array('_controller' => 'usuariosController::reporteAccesos', 'methods' => 'GET')));
$collection->attachRoute(new Route('/admin/reporteAccesos/', array('_controller' => 'usuariosController::getReporteAccesos', 'methods' => 'POST')));
$router = new Router($collection);
$router->setBasePath('/');
$route = $router->matchCurrentRequest();
if (!$route) {
    $page = new someController();
    $page->page404();
}