|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace ControleOnline\Controller; |
|
4
|
|
|
|
|
5
|
|
|
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface |
|
|
|
|
|
|
6
|
|
|
as Security; |
|
7
|
|
|
use Symfony\Component\HttpFoundation\JsonResponse; |
|
|
|
|
|
|
8
|
|
|
use Doctrine\ORM\EntityManagerInterface; |
|
|
|
|
|
|
9
|
|
|
use ControleOnline\Entity\Config; |
|
|
|
|
|
|
10
|
|
|
use ControleOnline\Service\DomainService; |
|
|
|
|
|
|
11
|
|
|
use ControleOnline\Service\FileService; |
|
|
|
|
|
|
12
|
|
|
use ControleOnline\Service\PeopleRoleService; |
|
13
|
|
|
|
|
14
|
|
|
class GetDefaultCompanyAction |
|
15
|
|
|
{ |
|
16
|
|
|
private $company; |
|
17
|
|
|
|
|
18
|
|
|
public function __construct( |
|
19
|
|
|
private Security $security, |
|
20
|
|
|
private EntityManagerInterface $em, |
|
21
|
|
|
private PeopleRoleService $roles, |
|
22
|
|
|
private FileService $fileService, |
|
23
|
|
|
private domainService $domainService |
|
24
|
|
|
) { |
|
25
|
|
|
|
|
26
|
|
|
$this->company = $this->roles->getMainCompany(); |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
public function __invoke(): JsonResponse |
|
30
|
|
|
{ |
|
31
|
|
|
|
|
32
|
|
|
try { |
|
33
|
|
|
|
|
34
|
|
|
|
|
35
|
|
|
$defaultCompany = []; |
|
36
|
|
|
$configs = []; |
|
37
|
|
|
$allConfigs = []; |
|
|
|
|
|
|
38
|
|
|
$token = $this->security->getToken(); |
|
39
|
|
|
$user = $token ? $token->getUser() : null; |
|
40
|
|
|
|
|
41
|
|
|
$permissions = $user ? $this->roles->getAllRoles($this->company) : ['guest']; |
|
42
|
|
|
|
|
43
|
|
|
if ($this->company) { |
|
44
|
|
|
$allConfigs = $this->em->getRepository(Config::class)->findBy([ |
|
45
|
|
|
'people' => $this->company->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->getId(), |
|
55
|
|
|
'alias' => $this->company->getAlias(), |
|
56
|
|
|
'configs' => $configs, |
|
57
|
|
|
'domainType' => $this->domainService->getPeopleDomain()->getDomainType(), |
|
58
|
|
|
'permissions' => $permissions, |
|
59
|
|
|
'theme' => $this->getTheme(), |
|
60
|
|
|
'logo' => $this->fileService->getFileUrl($this->company) |
|
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->domainService->getPeopleDomain()->getTheme()->getTheme(), |
|
89
|
|
|
'colors' => $this->domainService->getPeopleDomain()->getTheme()->getColors(), |
|
90
|
|
|
'background' => $this->domainService->getPeopleDomain()->getTheme()->getBackground() ? [ |
|
91
|
|
|
'id' => $this->domainService->getPeopleDomain()->getTheme()->getBackground(), |
|
92
|
|
|
'domain' => $this->domainService->getMainDomain(), |
|
93
|
|
|
'url' => '/files/' . $this->domainService->getPeopleDomain()->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