/**
  * Secured test.
  * @return void
  */
 public function testSecured()
 {
     $router = new SimpleRouter(array('id' => 12, 'any' => 'anyvalue'), SimpleRouter::SECURED);
     $httpRequest = new MockHttpRequest();
     $httpRequest->setQuery(array('presenter' => 'myPresenter'));
     $req = new PresenterRequest('othermodule:presenter', HttpRequest::GET, array());
     $url = $router->constructUrl($req, $httpRequest);
     $this->assertEquals("https://nettephp.com/file.php?presenter=othermodule%3Apresenter", $url);
 }
 public static function connect($route, $path, $options = array())
 {
     $fullPath = SimpleRouter::parsePath($path);
     return Router::connect($route, $fullPath, $options);
 }
<?php

App::uses('SimpleRouter', 'Lib');
Router::parseExtensions('csv', 'pdf', 'xlsx');
SimpleRouter::connect('/', 'admin/dashboard#home');
SimpleRouter::connect('/login', 'admin/users#login');
SimpleRouter::connect('/logout', 'admin/users#logout');
SimpleRouter::connect('/services/add', 'admin/services#add');
CakePlugin::routes();
require CAKE . 'Config' . DS . 'routes.php';
示例#4
0
<?php

// Configuration
require_once __DIR__ . '/../common.php';
try {
    // Router
    $r = new SimpleRouter();
    $r->route('/', 'index:index');
    // Default route
    $r->run($_SERVER['REQUEST_URI'], $_SERVER['SCRIPT_NAME']);
} catch (Exception $e) {
    echo _('Error:') . ' ' . $e->getMessage() . "\n";
}
/*
   Globals used in this application : 
   $me[] = array of key=>value pair : the current user from the User table.
   $class = name of the part of the application that we are executing (first part of the url which is http://domain.tld/class/action
   $action = the action requested. May be "" (=="list") or "edit", "doedit", "add", "doadd", "delete", "dodelete" ...
*/