public function chain(Zend_Controller_Router_Route_Interface $route, $separator = '/') { require_once 'Zend/Controller/Router/Route/Chain.php'; $chain = new Zend_Controller_Router_Route_Chain(); $chain->chain($this)->chain($route, $separator); return $chain; }
/** * Configure the Rest Router for API requests */ protected function _initRestRoute() { // Configure the Hostname Route for the api subdomain $op = $this->getOptions(); $hostnameRoute = new Zend_Controller_Router_Route_Hostname($op['api']['domain']); // Configure the REST Route to use the api module $front = Zend_Controller_Front::getInstance(); $pathRoute = new Zend_Rest_Route($front, array('module' => 'api')); // Chain the REST and Hostname routes $chainedRoute = new Zend_Controller_Router_Route_Chain(); $chainedRoute->chain($hostnameRoute)->chain($pathRoute); // Add the route to the REST controller using a Hostname Router $front->getRouter()->addRoute('api', $chainedRoute); }
/** * @group ZF-11442 */ public function testIsActiveIsChainedRouteAware() { // Create page $page = new Zend_Navigation_Page_Mvc(array('action' => 'myaction', 'route' => 'myroute', 'params' => array('page' => 1337, 'item' => 1234))); // Create chained route $chain = new Zend_Controller_Router_Route_Chain(); $foo = new Zend_Controller_Router_Route('lolcat/:action', array('module' => 'default', 'controller' => 'foobar', 'action' => 'bazbat')); $bar = new Zend_Controller_Router_Route(':page/:item', array('page' => 1, 'item' => 1)); $chain->chain($foo)->chain($bar); // Set up router $this->_front->getRouter()->addRoute('myroute', $chain); $this->_front->getRequest()->setParams(array('module' => 'default', 'controller' => 'foobar', 'action' => 'myaction', 'page' => 1337, 'item' => 1234)); // Test $this->assertTrue($page->isActive()); }
/** * @group ZF-11443 */ public function testGetDefaultsPriority() { // Create chained route $chain = new Zend_Controller_Router_Route_Chain(); $foo = new Zend_Controller_Router_Route_Hostname('www.zend.com', array('priority' => 1)); $bar = new Zend_Controller_Router_Route_Regex('bar', array('priority' => 2), array(), 'bar'); $baz = new Zend_Controller_Router_Route_Static('baz', array('priority' => 3)); $chain->chain($foo)->chain($bar)->chain($baz); // Get defaults $values = $chain->getDefaults(); // Test $this->assertSame(3, $values['priority']); }
public function testChainingAssembleWithRegex() { $chain = new Zend_Controller_Router_Route_Chain(); $foo = new Zend_Controller_Router_Route_Hostname('www.zend.com', array('foo' => 'foo')); $bar = new Zend_Controller_Router_Route_Regex('bar', array('bar' => 'bar'), array(), 'bar'); $chain->chain($foo)->chain($bar); $request = new Zend_Controller_Router_ChainTest_Request('http://www.zend.com/bar'); $res = $chain->match($request); $this->assertType('array', $res); $this->assertRegexp('#[^a-z0-9]?www\\.zend\\.com/bar$#i', $chain->assemble()); }
/** * Create a new chain * * @param Zend_Controller_Router_Route_Abstract $route * @param string $separator * @return Zend_Controller_Router_Route_Chain */ public function chain(Zend_Controller_Router_Route_Abstract $route, $separator = '/') { require_once LIB_DIR . '/Zend/Controller/Router/Route/Chain.php'; $chain = new Zend_Controller_Router_Route_Chain(); $chain->chain($this)->chain($route, $separator); return $chain; }
public function testAssemblingWithHostnameThroughChainHttp() { $foo = new Zend_Controller_Router_Route_Hostname('www.zend.com'); $bar = new Zend_Controller_Router_Route_Static('bar'); $chain = new Zend_Controller_Router_Route_Chain(); $chain->chain($foo)->chain($bar); $this->_router->addRoute('foo-bar', $chain); $this->assertEquals('http://www.zend.com/bar', $this->_router->assemble(array(), 'foo-bar')); }
/** * Create a new chain * * @param Zend_Controller_Router_Route_Abstract $route * @param string $separator * @return Zend_Controller_Router_Route_Chain */ public function chain(Zend_Controller_Router_Route_Abstract $route, $separator = '/') { $chain = new Zend_Controller_Router_Route_Chain(); $chain->chain($this)->chain($route, $separator); return $chain; }