1 | <?php |
||
2 | |||
3 | namespace ControleOnline\Service; |
||
4 | |||
5 | use ControleOnline\Entity\People; |
||
6 | use ControleOnline\Entity\PeopleDomain; |
||
7 | use ControleOnline\Entity\PeopleLink; |
||
8 | use Doctrine\ORM\EntityManagerInterface; |
||
0 ignored issues
–
show
|
|||
9 | use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface |
||
0 ignored issues
–
show
The type
Symfony\Component\Securi...e\TokenStorageInterface was not found. Maybe you did not declare it correctly or list all dependencies?
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
10 | AS Security; |
||
11 | use ControleOnline\Entity\User; |
||
0 ignored issues
–
show
The type
ControleOnline\Entity\User was not found. Maybe you did not declare it correctly or list all dependencies?
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
12 | |||
13 | class PeopleRoleService |
||
14 | { |
||
15 | |||
16 | private static $mainCompany; |
||
17 | |||
18 | public function __construct( |
||
19 | private EntityManagerInterface $manager, |
||
20 | private Security $security, |
||
21 | private DomainService $domainService |
||
0 ignored issues
–
show
The type
ControleOnline\Service\DomainService was not found. Maybe you did not declare it correctly or list all dependencies?
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
22 | ) {} |
||
23 | |||
24 | public function isFranchisee(People $people) |
||
25 | { |
||
26 | $mainCompany = $this->getMainCompany(); |
||
27 | |||
28 | return $this->manager->getRepository(People::class)->getCompanyPeopleLinks($mainCompany, $people, 'franchisee', 1); |
||
29 | } |
||
30 | |||
31 | |||
32 | public function isSalesman(People $people) |
||
33 | { |
||
34 | $mainCompany = $this->getMainCompany(); |
||
35 | $isSalesman = false; |
||
0 ignored issues
–
show
|
|||
36 | |||
37 | $isSalesman = $this->manager->getRepository(People::class)->getCompanyPeopleLinks($mainCompany, $people, 'salesman', 1); |
||
38 | if ($isSalesman) return true; |
||
39 | |||
40 | $getPeopleCompanies = $this->manager->getRepository(PeopleLink::class)->findBy([ |
||
41 | 'people' => $people, |
||
42 | 'link_type' => 'employee' |
||
43 | ]); |
||
44 | /** |
||
45 | * @var \ControleOnline\Entity\PeopleLink $peopleCompany |
||
46 | */ |
||
47 | foreach ($getPeopleCompanies as $peopleCompany) { |
||
48 | $isSalesman = $this->manager->getRepository(People::class)->getCompanyPeopleLinks($mainCompany, $peopleCompany->getCompany(), 'salesman', 1); |
||
49 | if ($isSalesman) return true; |
||
50 | } |
||
51 | return $isSalesman; |
||
52 | } |
||
53 | |||
54 | |||
55 | public function getAllRoles(People $people): array |
||
56 | { |
||
57 | $peopleRole = []; |
||
58 | $mainCompany = $this->getMainCompany(); |
||
59 | |||
60 | $isSuper = $this->manager->getRepository(People::class)->getCompanyPeopleLinks($mainCompany, $people, 'employee', 1); |
||
61 | if ($isSuper) |
||
62 | $peopleRole[] = 'super'; |
||
63 | |||
64 | |||
65 | |||
66 | $isFranchisee = $this->isFranchisee($people); |
||
67 | if ($isFranchisee) { |
||
68 | $peopleRole[] = 'franchisee'; |
||
69 | $peopleRole[] = 'admin'; |
||
70 | } |
||
71 | |||
72 | $isClient = $this->manager->getRepository(People::class)->getCompanyPeopleLinks($mainCompany, $people, 'client', 1); |
||
73 | if ($isClient) |
||
74 | $peopleRole[] = 'client'; |
||
75 | |||
76 | |||
77 | $isSalesman = $this->isSalesman($people); |
||
78 | if ($isSalesman) |
||
79 | $peopleRole[] = 'salesman'; |
||
80 | |||
81 | |||
82 | return array_values(array_unique(empty($peopleRole) ? ['guest'] : $peopleRole)); |
||
83 | } |
||
84 | |||
85 | /** |
||
86 | * Retorna a people da empresa principal segundo o dominio da api |
||
87 | * |
||
88 | * @return People |
||
89 | */ |
||
90 | public function getMainCompany(): People |
||
91 | { |
||
92 | |||
93 | if (self::$mainCompany) return self::$mainCompany; |
||
94 | |||
95 | $peopleDomain = $this->domainService->getPeopleDomain(); |
||
96 | self::$mainCompany = $peopleDomain->getPeople(); |
||
97 | |||
98 | return self::$mainCompany; |
||
99 | } |
||
100 | } |
||
101 |
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