/** * Test the before render method * * @return void */ public function testBeforeRender() { NavigationComponent::addTab('Settings', '/'); NavigationComponent::addTab('Tab 2', '/tab2'); $this->component->addToController($this->controller); $result = $this->controller->viewVars['navigation']['tabs']; $this->assertEquals([['title' => 'Settings', 'href' => '/', 'active' => true], ['title' => 'Tab 2', 'href' => '/tab2', 'active' => false]], $result); }
* to use (in this case, src/Template/Pages/home.ctp)... */ $routes->connect('/', ['controller' => 'Settings', 'action' => 'index']); /** * Connect catchall routes for all controllers. * * Using the argument `DashedRoute`, the `fallbacks` method is a shortcut for * `$routes->connect('/:controller', ['action' => 'index'], ['routeClass' => 'DashedRoute']);` * `$routes->connect('/:controller/:action/*', [], ['routeClass' => 'DashedRoute']);` * * Any route class can be used with this method, such as: * - DashedRoute * - InflectedRoute * - Route * - Or your own route class * * You can remove these routes once you've connected the * routes you want in your application. */ $routes->fallbacks('DashedRoute'); }); Router::scope('/api', function ($routes) { $routes->resources('Config'); }); NavigationComponent::addTab('Settings', '/'); NavigationComponent::addTab('Help', '/help'); /** * Load all plugin routes. See the Plugin documentation on * how to customize the loading of plugin routes. */ Plugin::routes();