diff --git a/src/Controller/AdminController.php b/src/Controller/AdminController.php index 02d97ea..f89a57f 100644 --- a/src/Controller/AdminController.php +++ b/src/Controller/AdminController.php @@ -678,44 +678,48 @@ class AdminController extends AbstractController return $response; } - #[Route('/watchdog', name: 'watchdog')] - #[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 + string $action = null, + string $id = null ): Response { - /** - * @var LogEntryRepository $logEntryRepository - */ - $logEntryRepository = $EntityManagerInterface->getRepository('Gedmo\Loggable\Entity\LogEntry'); $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'); + ->from('Gedmo\Loggable\Entity\LogEntry', 'l') + ->orderBy('l.objectClass', 'ASC'); - if (null != $type) { + $qbButtonsAction->select('DISTINCT l.action') + ->from('Gedmo\Loggable\Entity\LogEntry', 'l') + ->orderBy('l.action', 'ASC'); + + + + if (null != $type && '*' != $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); - } + 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); } $pagination = $paginator->paginate( @@ -725,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 4cdd176..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 }})
+{{ i.objectClass }} (# {{ i.objectId }}) {% if is_granted('ROLE_ADMIN') %}{% endif %}
{% endif %}{{ ('title_data_' ~ i.action)|trans }}