|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace ControleOnline\Service; |
|
4
|
|
|
|
|
5
|
|
|
use ControleOnline\Entity\Language; |
|
|
|
|
|
|
6
|
|
|
use ControleOnline\Entity\People; |
|
7
|
|
|
use ControleOnline\Entity\PeopleLink; |
|
8
|
|
|
use Doctrine\ORM\EntityManagerInterface; |
|
|
|
|
|
|
9
|
|
|
use Symfony\Component\HttpFoundation\RequestStack; |
|
|
|
|
|
|
10
|
|
|
use Symfony\Component\Security\Core\Security; |
|
|
|
|
|
|
11
|
|
|
|
|
12
|
|
|
class PeopleService |
|
13
|
|
|
{ |
|
14
|
|
|
|
|
15
|
|
|
public function __construct( |
|
16
|
|
|
private EntityManagerInterface $manager, |
|
17
|
|
|
private Security $security, |
|
18
|
|
|
private RequestStack $requestStack |
|
19
|
|
|
) { |
|
20
|
|
|
} |
|
21
|
|
|
|
|
22
|
|
|
public function beforePersist(People $people) |
|
23
|
|
|
{ |
|
24
|
|
|
$language = $this->manager->getRepository(Language::class)->findOneBy(['language' => 'pt-br']); |
|
25
|
|
|
$people->setLanguage($language); |
|
26
|
|
|
return $people; |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
public function afterPersist(People $people) |
|
30
|
|
|
{ |
|
31
|
|
|
$request = $this->requestStack->getCurrentRequest(); |
|
32
|
|
|
$payload = json_decode($request->getContent(), true); |
|
33
|
|
|
if (isset($payload->link_type)) { |
|
34
|
|
|
$company = $this->manager->getRepository(PeopleLink::class)->find($payload->company); |
|
35
|
|
|
$this->addLink($company, $people, $payload->link_type); |
|
36
|
|
|
} |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
public function addLink(People $company, People $people, $link_type) |
|
40
|
|
|
{ |
|
41
|
|
|
|
|
42
|
|
|
$peopleLink = $this->manager->getRepository(PeopleLink::class)->findOneBy([ |
|
43
|
|
|
'company' => $company, |
|
44
|
|
|
'people' => $people, |
|
45
|
|
|
'link_type' => $link_type |
|
46
|
|
|
]); |
|
47
|
|
|
|
|
48
|
|
|
if (!$peopleLink) |
|
49
|
|
|
$peopleLink = new PeopleLink(); |
|
50
|
|
|
|
|
51
|
|
|
$peopleLink->setCompany($company); |
|
52
|
|
|
$peopleLink->setPeople($people); |
|
53
|
|
|
$peopleLink->setLinkType($link_type); |
|
54
|
|
|
|
|
55
|
|
|
$this->manager->persist($peopleLink); |
|
56
|
|
|
$this->manager->flush(); |
|
57
|
|
|
|
|
58
|
|
|
return $peopleLink; |
|
59
|
|
|
} |
|
60
|
|
|
} |
|
61
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths