Issues (62)

Controller/UserLogsController.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace PiouPiou\RibsAdminBundle\Controller;
4
5
use PiouPiou\RibsAdminBundle\Entity\UserLogs;
6
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
7
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
8
use Symfony\Component\HttpFoundation\Response;
9
use Symfony\Component\Routing\Annotation\Route;
10
11
class UserLogsController extends AbstractController
12
{
13
    /**
14
     * list all user logs
15
     * @Route("/user-logs/{page}", requirements={"page" = "\d+"}, name="ribsadmin_userlogs")
16
     * @param ParameterBagInterface $parameterBag
17
     * @param int $page
18
     * @return Response
19
     */
20
    public function list(ParameterBagInterface $parameterBag, int $page = 1): Response
21
    {
22
        $em = $this->getDoctrine()->getManager();
23
        $max_per_page = $parameterBag->get("ribs_admin.paginator_element_per_page");
24
25
        $logs = $em->getRepository(UserLogs::class)->findAllPaginated($page, $max_per_page);
26
        $pagination = array(
27
            "page" => $page,
28
            "page_number" => ceil(count($logs) / 20),
29
            "route" => "ribsadmin_userlogs",
30
            "parameters" => array()
31
        );
32
33
        return $this->render("@RibsAdmin/userlogs/list.html.twig", [
34
            "logs" => $logs,
35
            "pagination" => $pagination
36
        ]);
37
    }
38
39
    /**
40
     * show detail of a user log
41
     * @Route("/user-logs/show/{guid}", name="ribsadmin_userlogs_show")
42
     * @param string $guid
43
     * @return Response
44
     */
45
    public function show(string $guid): Response
46
    {
47
        $log = $this->getDoctrine()->getRepository(UserLogs::class)->findOneByGuid($guid);
0 ignored issues
show
The method findOneByGuid() does not exist on PiouPiou\RibsAdminBundle...tory\UserLogsRepository. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

47
        $log = $this->getDoctrine()->getRepository(UserLogs::class)->/** @scrutinizer ignore-call */ findOneByGuid($guid);
Loading history...
48
49
        return $this->render("@RibsAdmin/userlogs/show.html.twig", [
50
            "log" => $log,
51
        ]);
52
    }
53
}
54