|
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 PROCERGS\LoginCidadao\CoreBundle\Service; |
|
12
|
|
|
|
|
13
|
|
|
use LoginCidadao\CoreBundle\Entity\PersonRepository; |
|
14
|
|
|
use LoginCidadao\CoreBundle\Entity\SentEmail; |
|
15
|
|
|
use LoginCidadao\CoreBundle\Model\IdentifiablePersonInterface; |
|
16
|
|
|
use LoginCidadao\CoreBundle\Model\PersonInterface; |
|
17
|
|
|
use LoginCidadao\SupportBundle\Model\SupportPerson; |
|
18
|
|
|
use LoginCidadao\SupportBundle\Service\SupportHandlerInterface; |
|
19
|
|
|
use PROCERGS\LoginCidadao\CoreBundle\Helper\MeuRSHelper; |
|
20
|
|
|
|
|
21
|
|
|
class SupportHandlerDecorator implements SupportHandlerInterface |
|
22
|
|
|
{ |
|
23
|
|
|
/** @var SupportHandlerInterface */ |
|
24
|
|
|
private $parent; |
|
25
|
|
|
|
|
26
|
|
|
/** @var MeuRSHelper */ |
|
27
|
|
|
private $rsHelper; |
|
28
|
|
|
|
|
29
|
|
|
/** @var PersonRepository */ |
|
30
|
|
|
private $personRepo; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* SupportHandlerDecorator constructor. |
|
34
|
|
|
* @param SupportHandlerInterface $parent |
|
35
|
|
|
* @param MeuRSHelper $rsHelper |
|
36
|
|
|
* @param PersonRepository $personRepo |
|
37
|
|
|
*/ |
|
38
|
2 |
|
public function __construct(SupportHandlerInterface $parent, MeuRSHelper $rsHelper, PersonRepository $personRepo) |
|
39
|
|
|
{ |
|
40
|
2 |
|
$this->parent = $parent; |
|
41
|
2 |
|
$this->rsHelper = $rsHelper; |
|
42
|
2 |
|
$this->personRepo = $personRepo; |
|
43
|
2 |
|
} |
|
44
|
|
|
|
|
45
|
1 |
|
public function getThirdPartyConnections(IdentifiablePersonInterface $person): array |
|
46
|
|
|
{ |
|
47
|
1 |
|
if (!$person instanceof PersonInterface) { |
|
48
|
1 |
|
$person = $this->personRepo->find($person->getId()); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
1 |
|
$connections = $this->parent->getThirdPartyConnections($person); |
|
|
|
|
|
|
52
|
|
|
|
|
53
|
1 |
|
if ($person instanceof PersonInterface) { |
|
54
|
1 |
|
$personRS = $this->rsHelper->getPersonMeuRS($person, true); |
|
55
|
|
|
|
|
56
|
1 |
|
$connections['nfg'] = $personRS->getNfgAccessToken() !== null; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
1 |
|
return $connections; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
1 |
|
public function getSupportPerson($id): SupportPerson |
|
63
|
|
|
{ |
|
64
|
1 |
|
return $this->parent->getSupportPerson($id); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
1 |
|
public function getPhoneMetadata(IdentifiablePersonInterface $person): array |
|
68
|
|
|
{ |
|
69
|
1 |
|
return $this->parent->getPhoneMetadata($person); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
1 |
|
public function getInitialMessage($ticket): ?SentEmail |
|
73
|
|
|
{ |
|
74
|
1 |
|
return $this->parent->getInitialMessage($ticket); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
1 |
|
public function getValidationMap(SupportPerson $person): array |
|
78
|
|
|
{ |
|
79
|
1 |
|
return $this->parent->getValidationMap($person); |
|
80
|
|
|
} |
|
81
|
|
|
} |
|
82
|
|
|
|