Неустранимая ошибка Cakephp v3 с классом пользовательского маршрутаPhp

Кемеровские программисты php общаются здесь
Anonymous
Неустранимая ошибка Cakephp v3 с классом пользовательского маршрута

Сообщение Anonymous »

Я пытаюсь использовать собственный класс маршрута.

Иногда я перенаправляюсь на URL-адреса, например

www.site.com/neumaticos-bridgestone


он ​​возвращает фатальную ошибку.

Но когда я обновляю страницу, ошибка скрывается

Я пытаюсь реализовать множество пользовательских классов маршрутов

routes.php

< pre class="lang-php Prettyprint-override">$routes->connect('/neumaticos-:marca', ['controller' => 'Pages', 'action' => 'brand'],
['routeClass' => 'BrandRoute'])
->setPass(['marca']);
$routes->connect('/neumaticos-para-:slug', ['controller' => 'Pages', 'action' => 'vehicleVersion'],
['routeClass' => 'VehicleVersionRoute'])
->setPass(['slug']);


BrandRoute.php

namespace Cake\Routing\Route;

use Cake\Utility\Inflector;
use Cake\ORM\TableRegistry;
use Cake\ORM\Query;

class BrandRoute extends Route
{

public function parse($url, $method = '')
{
$params = parent::parse($url, $method);
if (!$params) {
return false;
}
//return false;
$brands = TableRegistry::get('ProductBrands');

$slug = strtolower($params['marca']);
$brand = $brands->find()
->where([
'ProductBrands.slug' => $slug
])
->count();
if($brand > 0){
return $params;
}else{
return false;
}
return false;
}
}


Фатальная ошибка заключается в следующем:

Error: Cake\Routing\RouteCollection::parseRequest(): The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "Cake\Routing\Route\BrandRoute" of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide a __autoload() function to load the class definition
File /var/www/www.site.com/public_html/vendor/cakephp ... ection.php
Line: 205


Подробнее здесь: https://stackoverflow.com/questions/561 ... oute-class

Вернуться в «Php»