Ошибка в маршрутах ErrorException [ Recoverable Error ]: Object of class Closure could not be converted to string, как исправить?

Привет всем.
Не могу понять в чем проблема, но понимаю из-за чего, со старой коханы перекинул кусок маршрутов, и выдавать стало ошибку.

ErrorException [ Recoverable Error ]: Object of class Closure could not be converted to string

$expression = preg_replace('#'.Route::REGEX_ESCAPE.'#', '\\\\$0', $uri);

Маршрут:
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']))
    {	   
	  if (!isset($uri_segments[1])){
		return [
			'controller' => 'page',
			'action'     => 'views',
			'directory'  => 'index',
			'id'         => $alias,
			'alias'      => $alias,
		  ];  
	  }      
    }
    else
    {
		if (in_array($alias, array("category","product"))){
			return false;	
		}
		
      $alias = $uri_segments[count($uri_segments)-1];
      $product = ORM::factory('product')
        ->where('alias', '=', $alias)
        ->find();
      if ($product->loaded()){
		$countSegment =  Helper_Tree::getCountCategory($product->category)+1;  
		if ($countSegment==count($uri_segments)){
			return [
			  'controller' => 'category',
			  'action'     => 'product',
			  'directory'  => 'index',
			  'id'         => $alias,
			  'alias'      => $alias,
			];
		}else{
			return false;
		}
      }else{
        $cat = ORM::factory('category')
          ->where('alias', '=', $alias)
          ->find();
        if ($cat->loaded()){
			$countSegment =  Helper_Tree::getCountCategory($cat->parent_id)+1;  
			if ($countSegment==count($uri_segments)){
				return [
					'controller' => 'category',
					'action'     => 'views',
					'directory'  => 'index',
					'id'         => $alias,
					'alias'      => $alias,
				  ];	
			}else{
				return false;
			}
        }else{					
          if ((string)intval($alias)==$alias){
            //if (count($uri_segments)>1){
              $page = $uri_segments[count($uri_segments)-1];			  
              $alias = $uri_segments[count($uri_segments)-2];
			  return [
					'controller' => 'category',
					'action'     => 'views',
					'directory'  => 'index',
					'id'         => $alias,
					'alias'      => $alias,	
					'page'		=> $page
				  ];
            //}else{
            //  return false;	
            //}
          }else{
            return false;	
          }          
        }			
      }
    }
  }
);
  • Вопрос задан
  • 116 просмотров
Пригласить эксперта
Ответы на вопрос 1
ws17
@ws17 Автор вопроса
Разобрался, проблему решил, пришлось переписывать весь маршрут, плюс обновить его под новую кохану в этом и была проблема.
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы