diff --git a/src/Controller/AdminController.php b/src/Controller/AdminController.php index 9ed442b..02d97ea 100644 --- a/src/Controller/AdminController.php +++ b/src/Controller/AdminController.php @@ -679,10 +679,14 @@ class AdminController extends AbstractController } #[Route('/watchdog', name: 'watchdog')] + #[Route('/watchdog/{type}', name: 'watchdog_type')] + #[Route('/watchdog/{type}/{action}', name: 'watchdog_type_action')] public function watchdog( PaginatorInterface $paginator, Request $Request, - EntityManagerInterface $EntityManagerInterface + EntityManagerInterface $EntityManagerInterface, + string $type = null, + string $action = null ): Response { /** * @var LogEntryRepository $logEntryRepository @@ -690,11 +694,30 @@ class AdminController extends AbstractController $logEntryRepository = $EntityManagerInterface->getRepository('Gedmo\Loggable\Entity\LogEntry'); $qb = $EntityManagerInterface->createQueryBuilder(); + $qbButtons = $EntityManagerInterface->createQueryBuilder(); $qb->select('l') ->from('Gedmo\Loggable\Entity\LogEntry', 'l') ->orderBy('l.loggedAt', 'DESC'); + $qbButtons->select('DISTINCT l.objectClass') + ->from('Gedmo\Loggable\Entity\LogEntry', 'l') + ->orderBy('l.loggedAt', 'DESC'); + + if (null != $type) { + $qb->where('l.objectClass = :type'); + $qb->setParameter('type', 'App\Entity\\' . $type); + $qbButtonsAction = $EntityManagerInterface->createQueryBuilder(); + $qbButtonsAction->select('DISTINCT l.action') + ->from('Gedmo\Loggable\Entity\LogEntry', 'l') + ->orderBy('l.loggedAt', 'DESC'); + + if (null != $action) { + $qb->andWhere('l.action = :action'); + $qb->setParameter('action', $action); + } + } + $pagination = $paginator->paginate( $qb->getQuery()->getResult(), $Request->query->getInt('page', 1) @@ -702,7 +725,11 @@ class AdminController extends AbstractController return $this->render('admin/watchdog.html.twig', [ 'controller_name' => 'AdminController', - 'pagination' => $pagination + 'pagination' => $pagination, + 'buttonsType' => $qbButtons->getQuery()->getResult(), + 'type' => $type, + 'buttonsAction' => (($type != null) ? $qbButtonsAction->getQuery()->getResult() : null), + 'action' => $action, ]); } diff --git a/templates/admin/watchdog.html.twig b/templates/admin/watchdog.html.twig index 9c06ba6..3fa2e68 100644 --- a/templates/admin/watchdog.html.twig +++ b/templates/admin/watchdog.html.twig @@ -5,6 +5,26 @@ {% block body %} +