0

Помогите с настройками роутинг, есть следующий шаблон запросов с frontend: /books/([0-9]+)/book-authors/([0-9]+)/images

Есть контроллер располагается в namespace: Shop\Controllers\Books\BookAuthors\ImagesController

В контроллере есть метод indexAction.

В routing.php указываю следующее:

$router = new Router(false);

$router->removeExtraSlashes(true);
$router->setDefaultNamespace('Shop\Controllers');
$router->setDefaultController('index');
$router->setDefaultAction('index');

$router->addGet('/books/([0-9]+)/book-authors/([0-9]+)/images', [
    'namespace' => 'Shop\Controllers\Books\BookAuthors',
    'bookId' => 1,
    'authorId' => 2,
    'controller' => 'images',
    'action' => 'index',
]);
return $router;

На выходе, получаем, что редикрет всегда идет на default controller. Подскажите как исправить...

1 ответ 1

0

Проблема была в добавленном роуте /:controller/:action/:params, который отрабатывал раньше всех. Для решения можно роутингу /:controller/:action/:params указать позицию первый (FIRST) - так как в исходном коде phalcone идет обработка с конца в начало.

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.