You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
2.2KB

  1. <?php
  2. namespace App\Controller\Admin;
  3. use App\Entity\CollectifData\CollectifData;
  4. use EasyCorp\Bundle\EasyAdminBundle\Config\Action;
  5. use EasyCorp\Bundle\EasyAdminBundle\Config\Assets;
  6. use EasyCorp\Bundle\EasyAdminBundle\Config\MenuItem;
  7. use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator;
  8. use Lc\SovBundle\Controller\Dashboard\DashboardAdminController as SovDashboardController;
  9. use Symfony\Component\HttpFoundation\Response;
  10. class DashboardAnimatorController extends SovDashboardController
  11. {
  12. protected $adminUrlGenerator;
  13. public function __construct(AdminUrlGenerator $adminUrlGenerator)
  14. {
  15. $this->adminUrlGenerator = $adminUrlGenerator;
  16. }
  17. public function index(): Response
  18. {
  19. $urlCreate = $this->adminUrlGenerator
  20. ->setController(CollectifDataCrudController::class)
  21. ->setAction(Action::NEW)
  22. ->generateUrl();
  23. $nbForm = $this->getDoctrine()
  24. ->getRepository(CollectifData::class)
  25. ->findByUser($this->getUser());
  26. return $this->render(
  27. '/adminlte/dashboard-animator.html.twig',
  28. [
  29. 'urlCreate' => $urlCreate,
  30. 'nbForm' => count($nbForm),
  31. ]
  32. );
  33. }
  34. public function configureAssets(): Assets
  35. {
  36. $assets = parent::configureAssets(); // TODO: Change the autogenerated stub
  37. $assets->addWebpackEncoreEntry('app-backend');
  38. return $assets;
  39. }
  40. public function configureMenuItems(): iterable
  41. {
  42. $urlCreate = $this->adminUrlGenerator
  43. ->setController(CollectifDataCrudController::class)
  44. ->setAction(Action::NEW)
  45. ->generateUrl();
  46. yield MenuItem::linkToDashboard('dashboard', 'far fa-circle');
  47. yield MenuItem::linkToUrl('data_collectif_create', 'fas fa-plus', $urlCreate);
  48. yield MenuItem::subMenu('account', 'fas fa-user')
  49. ->setSubItems(
  50. [
  51. MenuItem::linkToRoute('account_profile', 'fas fa-user-cog', 'sov_admin_account_profile'),
  52. MenuItem::linkToRoute('account_password', 'fas fa-key', 'sov_admin_account_password'),
  53. ]
  54. );
  55. }
  56. }