Ergo\Routing\Router::lookup PHP Method

lookup() public method

Looks up a route match based on a url path
public lookup ( string $path ) : RouteMatch
$path string
return RouteMatch
    public function lookup($path)
    {
        if ($match = $this->_getRouteMatch($path, $this->_routes)) {
            return $match;
        }
        if ($match = $this->_getRouteMatch($path, $this->_customRoutes)) {
            return $match;
        }
        throw new LookupException("No route matches path '{$path}'");
    }

Usage Example

Ejemplo n.º 1
0
 public function testCustomRoute()
 {
     $urlPath = '/user/24';
     $mockRoute = \Mockery::mock('Erg\\Routing\\Route');
     $mockRoute->shouldReceive('getMatch')->with($urlPath, array())->once()->andReturn(new \Ergo\Routing\RouteMatch('user', array()))->shouldReceive('getName')->andReturn('user');
     $router = new Router();
     $router->connect($mockRoute, 'Custom.view');
     $this->assertEquals($router->lookup($urlPath)->getName(), 'user');
 }
All Usage Examples Of Ergo\Routing\Router::lookup