JazzCat
JazzCat

Reputation: 4573

CakePHP 3 override default route

Since Router::promote(); has been removed in CakePHP 3, what should one be using to override routes set in Config/routes.php from a plugin?

Say that i would want to overwrite

$routes->connect('/', ['controller' => 'Pages', 'action' => 'display', 'home']);

With

$routes->connect('/', ['plugin' => 'Plugin','controller' => 'Pages', 'action' => 'displayInPlugin']);

Upvotes: 1

Views: 843

Answers (1)

JazzCat
JazzCat

Reputation: 4573

Solution was to simply put Plugin::routes(); over the default routes...d'oh.

Plugin::routes();
Router::scope('/', function ($routes) {   
    $routes->connect('/', ['controller' => 'Pages', 'action' => 'display', 'home']);
    $routes->fallbacks('InflectedRoute');
});

Upvotes: 5

Related Questions