У меня неприятная ошибка в Cakephp 3.7.1.Я знаю, что похожая ошибка была зарегистрирована в https://discourse.cakephp.org/t/invoked-extension-not-recognized-configured-html/5355.
Ошибка в том, что расширение xml
работает, а расширение html
- нет.
Здесьмой файл маршрутов.
<?php
use Cake\Routing\Router;
use Cake\Routing\Route\DashedRoute;
Router::defaultRouteClass(DashedRoute::class);
$routesArray = [
'/' => [
'defaults' => [
'controller' => 'Pages',
'action' => 'view',
'home',
],
'options' => [],
],
'/pages/*' => [
'defaults' => [
'controller' => 'Pages',
'action' => 'display',
],
'options' => [],
],
'/pages/:page' => [
'defaults' => [
'controller' => 'Pages',
'action' => 'view',
],
'options' => [
'pass' => [
'page',
],
],
],
];
$languages = ['sn', 'fr', 'en'];
foreach ($languages as $language) {
Router::prefix($language, function ($routes) use ($routesArray, $language) {
$routes->setExtensions([
'xml',
'html',
]);
foreach ($routesArray as $key => $value) {
if (!empty($value['options']['_name'])) {
$value['options']['_name'] .= $language;
}
$routes->connect(
$key,
$value['defaults'],
$value['options']
);
}
$routes->fallbacks(DashedRoute::class);
});
}
Router::scope('/', function ($routes) use ($routesArray) {
$routes->setExtensions([
'xml',
'html',
]);
foreach ($routesArray as $key => $value) {
$routes->connect(
$key,
$value['defaults'],
$value['options']
);
}
$routes->fallbacks(DashedRoute::class);
});