categoryRepository = $categoryRepository; } /** * @return array */ public function getFunctions() { return [ new \Twig_SimpleFunction( 'category_name', function ($id) { if (!$ad = $this->dispatch(new GetCategoryName($id))) { return null; } return $ad; } ), new \Twig_SimpleFunction( 'category_detail', function ($id) { if (!$ad = $this->dispatch(new GetCategoryDetail($id))) { return null; } return $ad; } ), new \Twig_SimpleFunction( 'category_parents_name', function ($id) { return $this->categoryRepository->getParentCategoryById($id); } ), new \Twig_SimpleFunction( 'getParentsCount', function ($id) { return count($this->categoryRepository->getParentCategoryById($id)) - 1; } ), new \Twig_SimpleFunction( 'catIcon', function ($path) { if ($path == "") { return $this->dispatch(new MakeImageInstance('visiosoft.theme.base::images/default-categories-icon.png', 'img'))->url(); } else { return url('files/' . $path); } } ), new \Twig_SimpleFunction( 'getCategoriesLevel2', function () { if (!$getCategoriesLevel2 = $this->dispatch(new getCategoriesLevel2())) { return 0; } return $getCategoriesLevel2; } ) ]; } }