azine /
email-bundle
| 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 |
||
| 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
|
|||
| 47 | { |
||
| 48 | $email = $this->getDoctrine()->getManager()->getRepository(SentEmail::class) |
||
| 49 | ->findOneByToken($token); |
||
| 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 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.