Issues (114)

Controller/AzineEmailController.php (3 issues)

1
<?php
2
3
namespace Azine\EmailBundle\Controller;
4
5
use Azine\EmailBundle\Entity\Repositories\SentEmailRepository;
6
use Azine\EmailBundle\Entity\SentEmail;
7
use Azine\EmailBundle\Form\SentEmailType;
8
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
9
use Symfony\Component\HttpFoundation\Request;
10
use Symfony\Component\HttpFoundation\Response;
11
12
/**
13
 * This controller provides actions related to SentEmails stored in the database.
14
 */
15
class AzineEmailController extends Controller
0 ignored issues
show
Deprecated Code introduced by
The class Symfony\Bundle\Framework...e\Controller\Controller has been deprecated: since Symfony 4.2, use "Symfony\Bundle\FrameworkBundle\Controller\AbstractController" instead. ( Ignorable by Annotation )

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

15
class AzineEmailController extends /** @scrutinizer ignore-deprecated */ Controller
Loading history...
16
{
17
    /**
18
     *  Displays an Emails-Dashboard with filters for each property of SentEmails entity and links to
19
     *  emailDetailsByToken & webView actions for each email.
20
     *
21
     * @param Request $request
22
     *
23
     * @return Response
24
     */
25
    public function emailsDashboardAction(Request $request)
26
    {
27
        $form = $this->createForm(SentEmailType::class);
28
        $form->handleRequest($request);
29
        $searchParams = $form->getData();
30
        /** @var SentEmailRepository $repository */
31
        $repository = $this->getDoctrine()->getManager()->getRepository(SentEmail::class);
32
        $query = $repository->search($searchParams);
33
        $pagination = $this->get('knp_paginator')->paginate($query, $request->query->getInt('page', 1));
34
35
        return $this->render('AzineEmailBundle::emailsDashboard.html.twig',
36
            array('form' => $form->createView(), 'pagination' => $pagination));
37
    }
38
39
    /**
40
     * Displays an extended view of SentEmail entity searched by a token property.
41
     *
42
     * @param string $token
43
     *
44
     * @return Response
45
     */
46
    public function emailDetailsByTokenAction(Request $request, $token)
0 ignored issues
show
The parameter $request is not used and could be removed. ( Ignorable by Annotation )

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

46
    public function emailDetailsByTokenAction(/** @scrutinizer ignore-unused */ Request $request, $token)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
47
    {
48
        $email = $this->getDoctrine()->getManager()->getRepository(SentEmail::class)
49
            ->findOneByToken($token);
0 ignored issues
show
The method findOneByToken() does not exist on Doctrine\Common\Persistence\ObjectRepository. Did you maybe mean findOneBy()? ( Ignorable by Annotation )

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

49
            ->/** @scrutinizer ignore-call */ findOneByToken($token);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
50
51
        if ($email instanceof SentEmail) {
52
            $recipients = implode(', ', $email->getRecipients());
53
            $variables = implode(', ', array_keys($email->getVariables()));
54
55
            return $this->render('AzineEmailBundle::sentEmailDetails.html.twig',
56
                array('email' => $email, 'recipients' => $recipients, 'variables' => $variables));
57
        }
58
59
        // the parameters-array is null => the email is not available in webView
60
        $days = $this->getParameter('azine_email_web_view_retention');
61
        $response = $this->render('AzineEmailBundle:Webview:mail.not.available.html.twig', array('days' => $days));
62
        $response->setStatusCode(404);
63
64
        return $response;
65
    }
66
}
67