/** * Действие для страницы категории * * @param string $url URL категории * * @throws \Symfony\Component\HttpKernel\Exception\HttpException * * @return string */ public function categoryAction($url) { $category = $this->catalogModel->getCategory($url); if (!$category) { $this->app->abort(404, "Категория c URL '{$url}' не найдена"); } $products = $this->catalogModel->getProductsByCategoryId($category['id']); foreach ($products as &$product) { $product['price'] = $this->catalogModel->convertPrice($product['price']); } return $this->view->render('catalog/category.phtml', array('category' => $category, 'products' => $products)); }
/** * Действие для главной страницы * * @return string */ public function indexAction() { $categoriesTree = $this->catalogModel->getAllCategories(); $user = $this->app['session']->get('user'); return $this->view->render('index.phtml', array('categoriesTree' => $categoriesTree, 'user' => $user)); }