1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace ControleOnline\Service; |
4
|
|
|
|
5
|
|
|
use ControleOnline\Entity\Device; |
6
|
|
|
use ControleOnline\Entity\DeviceConfig; |
7
|
|
|
use ControleOnline\Entity\People; |
|
|
|
|
8
|
|
|
use Doctrine\ORM\EntityManagerInterface; |
|
|
|
|
9
|
|
|
|
10
|
|
|
class DeviceService |
11
|
|
|
{ |
12
|
|
|
public function __construct( |
13
|
|
|
private EntityManagerInterface $manager, |
14
|
|
|
private ConfigService $configService, |
15
|
|
|
) {} |
16
|
|
|
|
17
|
|
|
public function getPrinters(People $people) |
18
|
|
|
{ |
19
|
|
|
$device_configs = $this->manager->getRepository(DeviceConfig::class)->findBy([ |
20
|
|
|
'people' => $people |
21
|
|
|
]); |
22
|
|
|
$devices = []; |
23
|
|
|
foreach ($device_configs as $device_config) { |
24
|
|
|
$configs = $device_config->getConfigs(true); |
25
|
|
|
if (isset($configs['pos-gateway']) && $configs['pos-gateway'] == 'cielo') |
26
|
|
|
$devices[] = $device_config->getDevice(); |
27
|
|
|
} |
28
|
|
|
return $devices; |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
public function discoveryDevice($deviceId) |
32
|
|
|
{ |
33
|
|
|
$device = $this->manager->getRepository(Device::class)->findOneBy([ |
34
|
|
|
'device' => $deviceId |
35
|
|
|
]); |
36
|
|
|
if (!$device) { |
37
|
|
|
$device = new Device(); |
38
|
|
|
$device->setDevice($deviceId); |
39
|
|
|
$this->manager->persist($device); |
40
|
|
|
$this->manager->flush(); |
41
|
|
|
} |
42
|
|
|
return $device; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
|
46
|
|
|
public function discoveryDeviceConfig(Device $device, People $people): DeviceConfig |
47
|
|
|
{ |
48
|
|
|
$device_config = $this->manager->getRepository(DeviceConfig::class)->findOneBy([ |
49
|
|
|
'device' => $device, |
50
|
|
|
'people' => $people |
51
|
|
|
]); |
52
|
|
|
if (!$device_config) { |
53
|
|
|
$device_config = new DeviceConfig(); |
54
|
|
|
$device_config->setDevice($device); |
55
|
|
|
$device_config->setPeople($people); |
56
|
|
|
$this->manager->persist($device_config); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
return $device_config; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
public function addDeviceConfigs(People $people, array $configs, $deviceId) |
63
|
|
|
{ |
64
|
|
|
$device = $this->discoveryDevice($deviceId); |
65
|
|
|
|
66
|
|
|
$device_config = $this->discoveryDeviceConfig($device, $people); |
67
|
|
|
foreach ($configs as $key => $config) |
68
|
|
|
$device_config->addConfig($key, $config); |
69
|
|
|
|
70
|
|
|
$this->manager->persist($device_config); |
71
|
|
|
$this->manager->flush(); |
72
|
|
|
|
73
|
|
|
return $device_config; |
74
|
|
|
} |
75
|
|
|
} |
76
|
|
|
|
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