K
K
Kirill Gorlov2017-05-30 08:11:05
Kohana
Kirill Gorlov, 2017-05-30 08:11:05

How to nest controllers more in Kohana 3.3.*?

I use the kohana 3.3.6 framework in the project.
I am making a modular application structure, and the essence is as follows.
In the Personal Account (PC) of managers there is a Catalog section, for which it is responsible Controller_Manager_Catalog, also inside the catalog there are goods (Items) for which it is responsible Controller_Manager_Catalog_Items, and there are categories of goods Controller_Manager_Catalog_Categories.
The folder structure is as follows:

application/classes/Controller/Manager/Catalog.php
application/classes/Controller/Manager/Catalog/Categories.php
application/classes/Controller/Manager/Catalog/Items.php

Routing in the following format:
Route::set('manager', 'manager(/<controller>(/<action>(/<id>)))')
->defaults(array(
    'directory' => 'manager',
    'controller' => 'catalog',
    'action'     => 'index',
));

I'm trying to do something like this:
Route::set('manager-catalog', 'manager/catalog(/<controller>(/<action>(/<id>)))')
->defaults(array(
    'directory' => 'manager/catalog',
    'controller' => 'categories',
    'action'     => 'index',
));

but when I try to go to:
http://sitename.ru/manager/catalog/categories/index
gives an error 404.
More custom and personalized routes are higher than the general ones, i. that's not the problem.
The documentation structure is correct, but does not want to work.
Maybe someone faced with this need for such a placement? Tell me how did you solve this problem?
PS There are no problems with single-level nesting. Dances with a tambourine go exactly when a sub-sub directory of controllers is created.
Even if the root controller is changed (correct the name to something else), the problem does not disappear.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
entermix, 2017-06-11
@entermix

Do it like this:

Route::set('manager-catalog', 'manager/catalog(/<controller>(/<action>(/<id>)))')
->defaults(array(
    'directory' => 'manager/Catalog', // !
    'controller' => 'categories',
    'action'     => 'index',
));

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question