diff --git a/src/Controller/AdminController.php b/src/Controller/AdminController.php index 5bd8928..c4db8c9 100644 --- a/src/Controller/AdminController.php +++ b/src/Controller/AdminController.php @@ -679,48 +679,45 @@ class AdminController extends AbstractController } - #[Route('/watchdog', name: 'watchdog')] - #[Route('/watchdog/view/{type}/{id}/{action}', name: 'watchdog_view')] - #[Route('/watchdog/{type}', name: 'watchdog_type')] - #[Route('/watchdog/{type}/{action}', name: 'watchdog_type_action')] + #[Route('/watchdog/{type?*}/{id?*}/{action?*}', name: 'watchdog')] public function watchdog( PaginatorInterface $paginator, Request $Request, EntityManagerInterface $EntityManagerInterface, string $type = null, string $action = null, - int $id = null + string $id = null ): Response { $qb = $EntityManagerInterface->createQueryBuilder(); $qbButtons = $EntityManagerInterface->createQueryBuilder(); + $qbButtonsAction = $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'); + ->orderBy('l.objectClass', 'ASC'); + + $qbButtonsAction->select('DISTINCT l.action') + ->from('Gedmo\Loggable\Entity\LogEntry', 'l') + ->orderBy('l.action', 'ASC'); - if (null != $action) { - $qb->andWhere('l.action = :action'); - $qb->setParameter('action', $action); - } + + + if (null != $type && '*' != $type) { + $qb->where('l.objectClass = :type'); + $qb->setParameter('type', 'App\Entity\\' . $type); } - if (null != $id) { + if (null != $action && '*' != $action) { + $qb->andWhere('l.action = :action'); + $qb->setParameter('action', $action); + } + + if (null != $id && '*' != $id) { $qb->andWhere('l.objectId = :id'); $qb->setParameter('id', $id); } @@ -732,11 +729,13 @@ class AdminController extends AbstractController return $this->render('admin/watchdog.html.twig', [ 'controller_name' => 'AdminController', - 'pagination' => $pagination, - 'buttonsType' => $qbButtons->getQuery()->getResult(), 'type' => $type, - 'buttonsAction' => (($type != null) ? $qbButtonsAction->getQuery()->getResult() : null), 'action' => $action, + 'id' => $id, + 'buttonsType' => $qbButtons->getQuery()->getResult(), + 'buttonsAction' => $qbButtonsAction->getQuery()->getResult(), + 'pagination' => $pagination, + ]); } diff --git a/templates/_cells/historyDisplay.html.twig b/templates/_cells/historyDisplay.html.twig index e348a09..9d3c818 100644 --- a/templates/_cells/historyDisplay.html.twig +++ b/templates/_cells/historyDisplay.html.twig @@ -11,7 +11,7 @@ {% endif %}
{% if notype is not defined %} -{{ i.objectClass }} (# {{ i.objectId }}) {% if is_granted('ROLE_ADMIN') %}{% endif %}
+{{ i.objectClass }} (# {{ i.objectId }}) {% if is_granted('ROLE_ADMIN') %}{% endif %}
{% endif %}{{ ('title_data_' ~ i.action)|trans }}