Разные задачи для знатаков фраемворка kohana, ko7
Нужен программист, есть много разных задач которые нужно решать.
Первая задача, разобраться с маршрутизацией, со старой версии коханы перекинул маршрут на новую и выдает ошибку. Я пока не разобрался как ее решить.
Сам маршрут:
Route::set(
'page',
function ($uri) {
$db = Database::instance();
$uri_segments = explode('/', $uri);
$product = false;
$alias = $uri_segments[0];
$cat = ORM::factory('Page')
->where('alias', '=', $alias)
->find()
->as_array();
if (!empty($cat['id'])) {
return [
'controller' => 'page',
'action' => 'views',
'directory' => 'index',
'id' => $alias,
'alias' => $alias,
];
} else {
$cat = ORM::factory('Category')
->where('alias', '=', $alias)
->find();
if ($cat->loaded()) {
if (isset($uri_segments[1])) {
$alias = $uri_segments[1];
return [
'controller' => 'Category',
'action' => 'product',
'directory' => 'index',
'id' => $alias,
'alias' => $alias,
];
} else {
return [
'controller' => 'Category',
'action' => 'views',
'directory' => 'index',
'id' => $alias,
'alias' => $alias,
];
}
} else {
return false;
}
}
}
);
Ошибка такая:
ErrorException [ Recoverable Error ]: Object of class Closure could not be converted to string
$expression = preg_replace('#'.Route::REGEX_ESCAPE.'#', '\\\\$0', $uri);