1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace ControleOnline\Controller; |
4
|
|
|
|
5
|
|
|
use Symfony\Component\Security\Core\Security; |
|
|
|
|
6
|
|
|
use Symfony\Component\HttpFoundation\JsonResponse; |
|
|
|
|
7
|
|
|
use Symfony\Component\HttpFoundation\Request; |
|
|
|
|
8
|
|
|
use Doctrine\ORM\EntityManagerInterface; |
|
|
|
|
9
|
|
|
|
10
|
|
|
use ControleOnline\Entity\Config; |
|
|
|
|
11
|
|
|
use ControleOnline\Entity\PeopleDomain; |
12
|
|
|
use ControleOnline\Service\DomainService; |
|
|
|
|
13
|
|
|
use ControleOnline\Service\FileService; |
|
|
|
|
14
|
|
|
use ControleOnline\Service\PeopleRoleService; |
15
|
|
|
|
16
|
|
|
class GetDefaultCompanyAction |
17
|
|
|
{ |
18
|
|
|
|
19
|
|
|
|
20
|
|
|
private $company; |
21
|
|
|
|
22
|
|
|
public function __construct( |
23
|
|
|
private Security $security, |
24
|
|
|
private EntityManagerInterface $em, |
25
|
|
|
private PeopleRoleService $roles, |
26
|
|
|
private FileService $fileService, |
27
|
|
|
private domainService $domainService |
28
|
|
|
) {} |
29
|
|
|
|
30
|
|
|
public function __invoke(): JsonResponse |
31
|
|
|
{ |
32
|
|
|
|
33
|
|
|
try { |
34
|
|
|
|
35
|
|
|
|
36
|
|
|
$defaultCompany = []; |
37
|
|
|
$configs = []; |
38
|
|
|
$allConfigs = []; |
|
|
|
|
39
|
|
|
$user = $this->security->getUser(); |
40
|
|
|
|
41
|
|
|
$permissions = $user ? $this->roles->getAllRoles($user) : ['guest']; |
42
|
|
|
|
43
|
|
|
if ($this->company) { |
44
|
|
|
$allConfigs = $this->em->getRepository(Config::class)->findBy([ |
45
|
|
|
'people' => $this->company->getPeople()->getId(), |
46
|
|
|
'visibility' => 'public' |
47
|
|
|
]); |
48
|
|
|
|
49
|
|
|
foreach ($allConfigs as $config) { |
50
|
|
|
$configs[$config->getConfigKey()] = $config->getConfigValue(); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
$defaultCompany = [ |
54
|
|
|
'id' => $this->company->getPeople()->getId(), |
55
|
|
|
'alias' => $this->company->getPeople()->getAlias(), |
56
|
|
|
'configs' => $configs, |
57
|
|
|
'domainType' => $this->company->getDomainType(), |
58
|
|
|
'permissions' => $permissions, |
59
|
|
|
'theme' => $this->getTheme(), |
60
|
|
|
'logo' => $this->fileService->getFileUrl($this->company->getPeople()) |
61
|
|
|
]; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
return new JsonResponse([ |
65
|
|
|
'response' => [ |
66
|
|
|
'data' => $defaultCompany, |
67
|
|
|
'count' => 1, |
68
|
|
|
'error' => '', |
69
|
|
|
'success' => true |
70
|
|
|
], |
71
|
|
|
]); |
72
|
|
|
} catch (\Exception $e) { |
73
|
|
|
|
74
|
|
|
return new JsonResponse([ |
75
|
|
|
'response' => [ |
76
|
|
|
'data' => [], |
77
|
|
|
'count' => 0, |
78
|
|
|
'error' => $e->getMessage(), |
79
|
|
|
'success' => false, |
80
|
|
|
], |
81
|
|
|
]); |
82
|
|
|
} |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
private function getTheme() |
86
|
|
|
{ |
87
|
|
|
return [ |
88
|
|
|
'theme' => $this->company->getTheme()->getTheme(), |
89
|
|
|
'colors' => $this->company->getTheme()->getColors(), |
90
|
|
|
'background' => $this->company->getTheme()->getBackground() ? [ |
91
|
|
|
'id' => $this->company->getTheme()->getBackground(), |
92
|
|
|
'domain' => $this->domainService->getMainDomain(), |
93
|
|
|
'url' => '/files/' . $this->company->getTheme()->getBackground() . '/download' |
94
|
|
|
] : null, |
95
|
|
|
]; |
96
|
|
|
} |
97
|
|
|
} |
98
|
|
|
|
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