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\Component\HttpFoundation\Request; |
9
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
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
|
|
|
* @return Response |
23
|
|
|
*/ |
24
|
|
|
public function emailsDashboardAction(Request $request) |
25
|
|
|
{ |
26
|
|
|
$form = $this->createForm(new SentEmailType()); |
|
|
|
|
27
|
|
|
$form->handleRequest($request); |
28
|
|
|
$searchParams = $form->getData(); |
29
|
|
|
/** @var SentEmailRepository $repository */ |
30
|
|
|
$repository = $this->getDoctrine()->getManager()->getRepository(SentEmail::class); |
31
|
|
|
$query = $repository->search($searchParams); |
32
|
|
|
$pagination = $this->get('knp_paginator')->paginate($query, $request->query->getInt('page', 1)); |
33
|
|
|
|
34
|
|
|
return $this->render('AzineEmailBundle::emailsDashboard.html.twig', |
35
|
|
|
['form' => $form->createView(), 'pagination' => $pagination ]); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Displays an extended view of SentEmail entity searched by a token property |
40
|
|
|
* @param string $token |
41
|
|
|
* @return Response |
42
|
|
|
*/ |
43
|
|
|
public function emailDetailsByTokenAction(Request $request, $token) |
|
|
|
|
44
|
|
|
{ |
45
|
|
|
$email = $this->getDoctrine()->getManager()->getRepository(SentEmail::class) |
|
|
|
|
46
|
|
|
->findOneByToken($token); |
47
|
|
|
|
48
|
|
|
if($email instanceof SentEmail){ |
49
|
|
|
|
50
|
|
|
$recipients = implode(', ', $email->getRecipients()); |
51
|
|
|
$variables = implode(', ', array_keys($email->getVariables())); |
52
|
|
|
|
53
|
|
|
return $this->render('AzineEmailBundle::sentEmailDetails.html.twig', |
54
|
|
|
['email' => $email, 'recipients' => $recipients, 'variables' => $variables]); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
// the parameters-array is null => the email is not available in webView |
58
|
|
|
$days = $this->getParameter("azine_email_web_view_retention"); |
59
|
|
|
$response = $this->render("AzineEmailBundle:Webview:mail.not.available.html.twig", array('days' => $days)); |
60
|
|
|
$response->setStatusCode(404); |
61
|
|
|
|
62
|
|
|
return $response; |
63
|
|
|
} |
64
|
|
|
} |
65
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: