я основные маршруты установлены таким образом (слева только revelant часть):Zend 2 простой маршрут не работает правильно?
return array(
'controllers' => array(
'invokables' => array(
'Main\Controller\Login' => 'Main\Controller\LoginController',
'Main\Controller\Main' => 'Main\Controller\MainController',
'Main\Controller\Index' => 'Main\Controller\IndexController',
'Main\Controller\Candidate' => 'Main\Controller\CandidateController',
),
),
'router' => array(
'routes' => array(
'home' => array(
'type' => 'literal',
'options' => array(
'route' => '/',
'defaults' => array(
'controller' => 'Main\Controller\Index',
'action' => 'index',
),
),
),
'main' => array(
'type' => 'literal',
'options' => array(
'route' => '/ts',
'defaults' => array(
'controller' => 'Main\Controller\Main',
'action' => 'index',
),
),
'may_terminate' => true,
'child_routes' => array(
'candidates' => array(
'type' => 'literal',
'options' => array(
'route' => '/candidate',
'defaults' => array(
'controller' => 'Main\Controller\Candidate',
'action' => 'index'
),
),
'may_terminate' => true,
'child_routes' => array(
'add' => array(
'type' => 'literal',
'options' => array(
'route' => '/add'
),
'defaults' => array(
'action' => 'add'
),
),
),
),
),
),
),
),
Так что я считаю, что маршруты:
/
/ts
/ts/candidate
/ts/candidate/add
Все работает гладко, за исключением последнего один /ts/candidate/add
I сделаны некоторые основные виды, каждый возвращается просто
echo '<action_name>'
Где action_name
является действием контроллера. Но каждый раз, когда я вхожу /ts/candidate/add
, я получил index action
от
'Main\Controller\CandidateController'
вместо add action
. Посмотреть структура выглядит следующим образом:
view
-- errror
-- 404.phtml
-- index.phtml
-- layout
-- layout.phtml
-- login.phtml
-- main
-- candidate
-- index.phtml
-- add.phtml
-- main
-- index.phtml
Так очевидном :) Спасибо – kamil