@@ -19,13 +19,13 @@ |
||
19 | 19 | |
20 | 20 | public function getFileUrl(People $people): ?array |
21 | 21 | { |
22 | - if ($people->getImage() instanceof File) |
|
22 | + if ($people->getImage() instanceof File) |
|
23 | 23 | return [ |
24 | - 'id' => $people->getImage()->getId(), |
|
25 | - 'domain' => $this->domainService->getMainDomain(), |
|
26 | - 'url' => '/files/' . $people->getImage()->getId() . '/download' |
|
24 | + 'id' => $people->getImage()->getId(), |
|
25 | + 'domain' => $this->domainService->getMainDomain(), |
|
26 | + 'url' => '/files/' . $people->getImage()->getId() . '/download' |
|
27 | 27 | ]; |
28 | 28 | |
29 | - return null; |
|
29 | + return null; |
|
30 | 30 | } |
31 | 31 | } |
@@ -19,12 +19,13 @@ |
||
19 | 19 | |
20 | 20 | public function getFileUrl(People $people): ?array |
21 | 21 | { |
22 | - if ($people->getImage() instanceof File) |
|
23 | - return [ |
|
22 | + if ($people->getImage() instanceof File) { |
|
23 | + return [ |
|
24 | 24 | 'id' => $people->getImage()->getId(), |
25 | 25 | 'domain' => $this->domainService->getMainDomain(), |
26 | 26 | 'url' => '/files/' . $people->getImage()->getId() . '/download' |
27 | 27 | ]; |
28 | + } |
|
28 | 29 | |
29 | 30 | return null; |
30 | 31 | } |
@@ -57,11 +57,11 @@ |
||
57 | 57 | { |
58 | 58 | if (self::$peopleDomain) return self::$peopleDomain; |
59 | 59 | |
60 | - $domain = $this->getDomain(); |
|
60 | + $domain = $this->getDomain(); |
|
61 | 61 | self::$peopleDomain = $this->manager->getRepository(PeopleDomain::class)->findOneBy(['domain' => $domain]); |
62 | 62 | |
63 | 63 | if (!self::$peopleDomain) { |
64 | - $domain = $this->getMainDomain(); |
|
64 | + $domain = $this->getMainDomain(); |
|
65 | 65 | self::$peopleDomain = $this->manager->getRepository(PeopleDomain::class)->findOneBy(['domain' => $domain]); |
66 | 66 | } |
67 | 67 |
@@ -43,8 +43,9 @@ discard block |
||
43 | 43 | ) |
44 | 44 | )); |
45 | 45 | |
46 | - if (!$domain) |
|
47 | - throw new InvalidArgumentException('Please define header or get param "app-domain"', 301); |
|
46 | + if (!$domain) { |
|
47 | + throw new InvalidArgumentException('Please define header or get param "app-domain"', 301); |
|
48 | + } |
|
48 | 49 | return $domain; |
49 | 50 | } |
50 | 51 | |
@@ -55,7 +56,9 @@ discard block |
||
55 | 56 | |
56 | 57 | public function getPeopleDomain(): PeopleDomain |
57 | 58 | { |
58 | - if (self::$peopleDomain) return self::$peopleDomain; |
|
59 | + if (self::$peopleDomain) { |
|
60 | + return self::$peopleDomain; |
|
61 | + } |
|
59 | 62 | |
60 | 63 | $domain = $this->getDomain(); |
61 | 64 | self::$peopleDomain = $this->manager->getRepository(PeopleDomain::class)->findOneBy(['domain' => $domain]); |
@@ -65,10 +68,11 @@ discard block |
||
65 | 68 | self::$peopleDomain = $this->manager->getRepository(PeopleDomain::class)->findOneBy(['domain' => $domain]); |
66 | 69 | } |
67 | 70 | |
68 | - if (self::$peopleDomain === null) |
|
69 | - throw new \Exception( |
|
71 | + if (self::$peopleDomain === null) { |
|
72 | + throw new \Exception( |
|
70 | 73 | sprintf('Main company "%s" not found', $domain) |
71 | 74 | ); |
75 | + } |
|
72 | 76 | |
73 | 77 | return self::$peopleDomain; |
74 | 78 | } |
@@ -39,10 +39,12 @@ |
||
39 | 39 | $fileType = explode('/', $file->getClientMimeType()); |
40 | 40 | $originalFilename = $file->getClientOriginalName(); |
41 | 41 | |
42 | - if ($file_id) |
|
43 | - $fileEntity = $this->em->getRepository(File::class)->find($file_id); |
|
44 | - if (!$fileEntity) |
|
45 | - $fileEntity = new File(); |
|
42 | + if ($file_id) { |
|
43 | + $fileEntity = $this->em->getRepository(File::class)->find($file_id); |
|
44 | + } |
|
45 | + if (!$fileEntity) { |
|
46 | + $fileEntity = new File(); |
|
47 | + } |
|
46 | 48 | |
47 | 49 | $fileEntity->setContext($context); |
48 | 50 | $fileEntity->setContent($content); |
@@ -64,7 +64,7 @@ |
||
64 | 64 | |
65 | 65 | //$this->manager->persist($entity); |
66 | 66 | } else { |
67 | - $json = json_decode($this->request->getContent(), true); |
|
67 | + $json = json_decode($this->request->getContent(), true); |
|
68 | 68 | $extra_data = isset($json['extra-data']) ? $json['extra-data'] : null; |
69 | 69 | if (!$extra_data) |
70 | 70 | return; |
@@ -7,7 +7,7 @@ |
||
7 | 7 | use ControleOnline\Entity\ExtraData; |
8 | 8 | use ControleOnline\Entity\ExtraFields; |
9 | 9 | use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface |
10 | - AS Security; |
|
10 | + AS Security; |
|
11 | 11 | use Symfony\Component\Serializer\SerializerInterface; |
12 | 12 | use Symfony\Component\HttpFoundation\RequestStack; |
13 | 13 |
@@ -36,8 +36,9 @@ discard block |
||
36 | 36 | |
37 | 37 | public function discoveryDevice(&$entity) |
38 | 38 | { |
39 | - if ($entity instanceof Device || $entity instanceof DeviceConfig) |
|
40 | - return; |
|
39 | + if ($entity instanceof Device || $entity instanceof DeviceConfig) { |
|
40 | + return; |
|
41 | + } |
|
41 | 42 | |
42 | 43 | $deviceId = $this->request->headers->get('DEVICE') ?: $this->getUserIp(); |
43 | 44 | if (method_exists($entity, 'setDevice')) { |
@@ -48,14 +49,16 @@ discard block |
||
48 | 49 | |
49 | 50 | public function discoveryUser(&$entity) |
50 | 51 | { |
51 | - if (method_exists($entity, 'setUser')) |
|
52 | - $entity->setUser($this->security->getToken()->getUser()); |
|
52 | + if (method_exists($entity, 'setUser')) { |
|
53 | + $entity->setUser($this->security->getToken()->getUser()); |
|
54 | + } |
|
53 | 55 | } |
54 | 56 | |
55 | 57 | public function persist(&$entity) |
56 | 58 | { |
57 | - if (self::$persisted == true) |
|
58 | - return; |
|
59 | + if (self::$persisted == true) { |
|
60 | + return; |
|
61 | + } |
|
59 | 62 | self::$persisted = true; |
60 | 63 | |
61 | 64 | //$this->manager->persist($entity); |
@@ -73,15 +76,17 @@ discard block |
||
73 | 76 | } else { |
74 | 77 | $json = json_decode($this->request->getContent(), true); |
75 | 78 | $extra_data = isset($json['extra-data']) ? $json['extra-data'] : null; |
76 | - if (!$extra_data) |
|
77 | - return; |
|
79 | + if (!$extra_data) { |
|
80 | + return; |
|
81 | + } |
|
78 | 82 | $entity_id = $extra_data['entity_id']; |
79 | 83 | $entity_name = $extra_data['entity_name']; |
80 | 84 | } |
81 | 85 | |
82 | 86 | |
83 | - if (!$entity_id || !$entity_name) |
|
84 | - return; |
|
87 | + if (!$entity_id || !$entity_name) { |
|
88 | + return; |
|
89 | + } |
|
85 | 90 | |
86 | 91 | foreach ($extra_data['data'] as $key => $data) { |
87 | 92 | $extra_fields = $this->manager->getRepository(ExtraFields::class)->find($key); |
@@ -92,8 +97,9 @@ discard block |
||
92 | 97 | 'extra_fields' => $extra_fields |
93 | 98 | ]); |
94 | 99 | |
95 | - if (!$extraData) |
|
96 | - $extraData = new ExtraData(); |
|
100 | + if (!$extraData) { |
|
101 | + $extraData = new ExtraData(); |
|
102 | + } |
|
97 | 103 | |
98 | 104 | $extraData->setExtraFields($extra_fields); |
99 | 105 | $extraData->setEntityName($entity_name); |
@@ -14,8 +14,8 @@ |
||
14 | 14 | */ |
15 | 15 | class ModuleRepository extends ServiceEntityRepository |
16 | 16 | { |
17 | - public function __construct(ManagerRegistry $registry) |
|
18 | - { |
|
17 | + public function __construct(ManagerRegistry $registry) |
|
18 | + { |
|
19 | 19 | parent::__construct($registry, Module::class); |
20 | - } |
|
20 | + } |
|
21 | 21 | } |
@@ -54,8 +54,9 @@ |
||
54 | 54 | if (method_exists($service, $method)) { |
55 | 55 | $newEntity = $service->$method($entity); |
56 | 56 | |
57 | - if ('postPersist' === $method && $newEntity) |
|
58 | - $this->manager->refresh($newEntity); |
|
57 | + if ('postPersist' === $method && $newEntity) { |
|
58 | + $this->manager->refresh($newEntity); |
|
59 | + } |
|
59 | 60 | } |
60 | 61 | } |
61 | 62 | return $entity; |
@@ -20,7 +20,7 @@ |
||
20 | 20 | public function addLine($prefix = '', $suffix = '', $delimiter = ' ') |
21 | 21 | { |
22 | 22 | $initialSpace = str_repeat(" ", $this->initialSpace); |
23 | - $count = $this->totalChars - $this->initialSpace - strlen($prefix) - strlen($suffix); |
|
23 | + $count = $this->totalChars - $this->initialSpace - strlen($prefix) - strlen($suffix); |
|
24 | 24 | if ($count > 0) |
25 | 25 | $delimiter = str_repeat($delimiter, $count); |
26 | 26 | $this->text .= $initialSpace . $prefix . $delimiter . $suffix . "\n"; |
@@ -21,8 +21,9 @@ |
||
21 | 21 | { |
22 | 22 | $initialSpace = str_repeat(" ", $this->initialSpace); |
23 | 23 | $count = $this->totalChars - $this->initialSpace - strlen($prefix) - strlen($suffix); |
24 | - if ($count > 0) |
|
25 | - $delimiter = str_repeat($delimiter, $count); |
|
24 | + if ($count > 0) { |
|
25 | + $delimiter = str_repeat($delimiter, $count); |
|
26 | + } |
|
26 | 27 | $this->text .= $initialSpace . $prefix . $delimiter . $suffix . "\n"; |
27 | 28 | } |
28 | 29 |
@@ -13,22 +13,22 @@ |
||
13 | 13 | |
14 | 14 | class DiscoveryMainConfigsAction |
15 | 15 | { |
16 | - public function __construct( |
|
16 | + public function __construct( |
|
17 | 17 | private EntityManagerInterface $manager, |
18 | 18 | private HydratorService $hydratorService, |
19 | 19 | private ConfigService $configService |
20 | - ) {} |
|
20 | + ) {} |
|
21 | 21 | |
22 | - public function __invoke(Request $request): JsonResponse |
|
23 | - { |
|
22 | + public function __invoke(Request $request): JsonResponse |
|
23 | + { |
|
24 | 24 | try { |
25 | - $json = json_decode($request->getContent(), true); |
|
26 | - $device = $this->manager->getRepository(People::class)->findOneBy(['device' => $request->headers->get('device')]); |
|
27 | - $people = $this->manager->getRepository(People::class)->find(preg_replace("/[^0-9]/", "", $json['people'])); |
|
28 | - $configs = $this->configService->discoveryMainConfigs($people, $device); |
|
29 | - return new JsonResponse($this->hydratorService->collectionData($configs, Config::class, 'config:read')); |
|
25 | + $json = json_decode($request->getContent(), true); |
|
26 | + $device = $this->manager->getRepository(People::class)->findOneBy(['device' => $request->headers->get('device')]); |
|
27 | + $people = $this->manager->getRepository(People::class)->find(preg_replace("/[^0-9]/", "", $json['people'])); |
|
28 | + $configs = $this->configService->discoveryMainConfigs($people, $device); |
|
29 | + return new JsonResponse($this->hydratorService->collectionData($configs, Config::class, 'config:read')); |
|
30 | 30 | } catch (Exception $e) { |
31 | - return new JsonResponse($this->hydratorService->error($e)); |
|
31 | + return new JsonResponse($this->hydratorService->error($e)); |
|
32 | + } |
|
32 | 33 | } |
33 | - } |
|
34 | 34 | } |
@@ -14,23 +14,23 @@ |
||
14 | 14 | |
15 | 15 | class AddDeviceConfigAction |
16 | 16 | { |
17 | - public function __construct( |
|
17 | + public function __construct( |
|
18 | 18 | private EntityManagerInterface $manager, |
19 | 19 | private HydratorService $hydratorService, |
20 | 20 | private DeviceService $deviceService |
21 | - ) {} |
|
21 | + ) {} |
|
22 | 22 | |
23 | - public function __invoke(Request $request): JsonResponse |
|
24 | - { |
|
23 | + public function __invoke(Request $request): JsonResponse |
|
24 | + { |
|
25 | 25 | try { |
26 | - $json = json_decode($request->getContent(), true); |
|
27 | - $device = $request->headers->get('device'); |
|
28 | - $people = $this->manager->getRepository(People::class)->find(preg_replace("/[^0-9]/", "", $json['people'])); |
|
29 | - $configs = json_decode($json['configs'], true); |
|
30 | - $device_config = $this->deviceService->addDeviceConfigs($people, $configs, $device); |
|
31 | - return new JsonResponse($this->hydratorService->item(DeviceConfig::class, $device_config->getId(), 'device_config:read'), Response::HTTP_OK); |
|
26 | + $json = json_decode($request->getContent(), true); |
|
27 | + $device = $request->headers->get('device'); |
|
28 | + $people = $this->manager->getRepository(People::class)->find(preg_replace("/[^0-9]/", "", $json['people'])); |
|
29 | + $configs = json_decode($json['configs'], true); |
|
30 | + $device_config = $this->deviceService->addDeviceConfigs($people, $configs, $device); |
|
31 | + return new JsonResponse($this->hydratorService->item(DeviceConfig::class, $device_config->getId(), 'device_config:read'), Response::HTTP_OK); |
|
32 | 32 | } catch (Exception $e) { |
33 | - return new JsonResponse($this->hydratorService->error($e)); |
|
33 | + return new JsonResponse($this->hydratorService->error($e)); |
|
34 | + } |
|
34 | 35 | } |
35 | - } |
|
36 | 36 | } |