Completed
Pull Request — master (#317)
by Guilherme
04:03
created

TwigSwiftMailer::sendAccountAutoBlockedMessage()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 1
dl 0
loc 9
ccs 0
cts 7
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * This file is part of the login-cidadao project or it's bundles.
4
 *
5
 * (c) Guilherme Donato <guilhermednt on github>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace LoginCidadao\CoreBundle\Mailer;
12
13
use FOS\UserBundle\Mailer\TwigSwiftMailer as BaseMailer;
14
use FOS\UserBundle\Model\UserInterface;
15
use LoginCidadao\CoreBundle\Model\PersonInterface;
16
17
class TwigSwiftMailer extends BaseMailer
18
{
19
    protected $mailerSenderMail;
20
21
    public function setMailerSenderMail($var)
22
    {
23
        $this->mailerSenderMail = $var;
24
    }
25
26
    public function sendEmailChangedMessage(UserInterface $user, $oldEmail)
27
    {
28
        $template = $this->parameters['template']['email_changed'];
29
        $fromEmail = $this->parameters['from_email']['email_changed'];
30
        $fromName = $this->parameters['from_email']['email_sender_name'];
31
        $from = [$fromEmail => $fromName];
32
33
        $context = [
34
            'user' => $user,
35
            'oldEmail' => $oldEmail,
36
        ];
37
38
        $this->sendMessage($template, $context, $from, $oldEmail);
39
    }
40
41
    public function sendAccountBlockedMessage(PersonInterface $person)
42
    {
43
        $template = $this->parameters['template']['account_blocked'];
44
        $fromEmail = $this->parameters['from_email']['account_blocked'];
45
        $fromName = $this->parameters['from_email']['email_sender_name'];
46
        $from = [$fromEmail => $fromName];
47
48
        $context = ['email' => $person->getEmail()];
49
        $this->sendMessage($template, $context, $from, $person->getEmail());
50
    }
51
52
    public function sendAccountAutoBlockedMessage(PersonInterface $person)
53
    {
54
        $template = $this->parameters['template']['account_auto_blocked'];
55
        $fromEmail = $this->parameters['from_email']['account_auto_blocked'];
56
        $fromName = $this->parameters['from_email']['email_sender_name'];
57
        $from = [$fromEmail => $fromName];
58
59
        $context = ['email' => $person->getEmail()];
60
        $this->sendMessage($template, $context, $from, $person->getEmail());
61
    }
62
}
63