1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Azine\EmailBundle\Controller; |
4
|
|
|
|
5
|
|
|
|
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
|
|
|
|
11
|
|
|
class AzineEmailController extends Controller |
12
|
|
|
{ |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Emails-Dashboard |
16
|
|
|
*/ |
17
|
|
|
public function emailsDashboardAction(Request $request) |
18
|
|
|
{ |
19
|
|
|
$form = $this->createForm(new SentEmailType()); |
|
|
|
|
20
|
|
|
|
21
|
|
|
$form->handleRequest($request); |
22
|
|
|
|
23
|
|
|
$repository = $this->getDoctrine()->getManager()->getRepository(SentEmail::class); |
24
|
|
|
$queryBuilder = $repository->search($form->getData()); |
25
|
|
|
|
26
|
|
|
$paginator = $this->get('azine.email.bundle.pagination'); |
27
|
|
|
|
28
|
|
|
$paginator->setTotalCount($repository->getTotalCount($queryBuilder)); |
29
|
|
|
|
30
|
|
|
$queryBuilder->setMaxResults($paginator->getPageSize()) |
31
|
|
|
->setFirstResult($paginator->getOffset()); |
32
|
|
|
|
33
|
|
|
$emails = $queryBuilder->getQuery()->getResult(); |
34
|
|
|
$emailsArray = []; |
35
|
|
|
|
36
|
|
|
foreach ($emails as $key => $email){ |
37
|
|
|
|
38
|
|
|
$emailsArray[$key]['recipients'] = implode(', ', $email->getRecipients()); |
39
|
|
|
$emailsArray[$key]['template'] = $email->getTemplate(); |
40
|
|
|
$emailsArray[$key]['sent'] = $email->getSent()->format('Y-m-d H:i:s'); |
41
|
|
|
$emailsArray[$key]['variables'] = substr(json_encode($email->getVariables()), 0, 60); |
42
|
|
|
$emailsArray[$key]['token'] = $email->getToken(); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
return $this->render('AzineEmailBundle::emailsDashboard.html.twig', ['paginator' => $paginator, |
46
|
|
|
'emails' => $emailsArray, 'form' => $form->createView()]); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
public function getEmailDetailsByTokenAction(Request $request, $token) |
|
|
|
|
50
|
|
|
{ |
51
|
|
|
$email = $this->getDoctrine()->getManager()->getRepository(SentEmail::class) |
52
|
|
|
->findOneByToken($token); |
53
|
|
|
|
54
|
|
|
if($email instanceof SentEmail){ |
55
|
|
|
|
56
|
|
|
$recipients = implode(', ', $email->getRecipients()); |
57
|
|
|
$variables = implode(', ', array_keys($email->getVariables())); |
58
|
|
|
|
59
|
|
|
return $this->render('AzineEmailBundle::sentEmailDetails.html.twig', |
60
|
|
|
['email' => $email, 'recipients' => $recipients, 'variables' => $variables]); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
$response = $this->render("AzineEmailBundle::emailNotFound.html.twig"); |
64
|
|
|
$response->setStatusCode(404); |
65
|
|
|
|
66
|
|
|
return $response; |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|
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: