attach() 공개 정적인 메소드

Example 1: Router::attach('app', array( 'absolute' => true, 'host' => 'localhost', 'scheme' => 'http://', 'prefix' => 'web/tests' )); Example 2: Router::attach('app', array( 'absolute' => true, 'host' => '{:subdomain:[a-z]+}.{:hostname}.{:tld}', 'scheme' => '{:scheme:https://}', 'prefix' => '' )); Attach the variables to populate for the app scope. Router::attach('app', null, array( 'subdomain' => 'www', 'hostname' => 'li3', 'tld' => 'me' ));
public static attach ( $name, $config = null, array $vars = [] )
$vars array
예제 #1
0
 protected function _restoreCtrlContext()
 {
     Router::reset();
     foreach ($this->_context['routes'] as $scope => $routes) {
         Router::scope($scope, function () use($routes) {
             foreach ($routes as $route) {
                 Router::connect($route);
             }
         });
     }
     foreach ($this->_context['scopes'] as $scope => $attachment) {
         Router::attach($scope, $attachment);
     }
     Router::scope($this->_context['scope']);
 }
예제 #2
0
 public function testMatchWithAbsoluteScope()
 {
     Router::attach('app', array('absolute' => true, 'host' => '{:domain}'));
     Router::scope('app', function () {
         Router::connect('/hello', 'Posts::index');
     });
     $request = new Request(array('url' => '/hello', 'base' => ''));
     $result = Router::process($request);
     $expected = 'http://' . $result->params['domain'] . '/hello';
     $result = Router::match($result->params, $request);
     $this->assertEqual($expected, $result);
 }
예제 #3
0
 public function testScopeBase()
 {
     $request = new Request(array('base' => 'lithium/app'));
     $url = array('controller' => 'HelloWorld');
     Router::scope('app', function () {
         Router::connect('/{:controller}/{:action}');
     });
     Router::scope('app');
     $expected = '/lithium/app/hello_world';
     $this->assertEqual($expected, Router::match($url, $request));
     Router::attach('app', array('base' => 'lithium'));
     $expected = '/lithium/hello_world';
     $this->assertEqual($expected, Router::match($url, $request));
     Router::attach('app', array('base' => ''));
     $expected = '/hello_world';
     $this->assertEqual($expected, Router::match($url, $request));
 }