<?php
namespace App\Twig\Globals;
class MenuHelper {
public function __construct(
\App\Repository\MenuRepository $menuRepository,
\Symfony\Component\Routing\Generator\UrlGeneratorInterface $router
) {
$this->router = $router;
$this->menuRepository = $menuRepository;
}
public function getCareerPathsMenu() {
$menuItems = $this->menuRepository->findBy(["isEnabled" => "true", "type" => \App\DBAL\Types\MenuType::CAREER_PATH], ["position" => "ASC"]);
$items = [];
foreach ($menuItems as $item) :
$items[] = [
"title" => $item->getTitle(),
"path" => $this->router->generate('client_career_path_category_list', ["slug" => $item->getCareerPathCategory()->getSlug()])
];
endforeach;
return $items;
}
public function getCoursesMenu() {
$menuItems = $this->menuRepository->findBy(["isEnabled" => "true", "type" => \App\DBAL\Types\MenuType::COURSE], ["position" => "ASC"]);
$items = [];
foreach ($menuItems as $item) :
$items[] = [
"title" => $item->getTitle(),
"path" => $this->router->generate('client_course_category_list', ["slug" => $item->getCourseCategory()->getSlug()])
];
endforeach;
return $items;
}
}