ControleOnline /
api-platform-common
| 1 | <?php |
||
| 2 | |||
| 3 | namespace ControleOnline\Service; |
||
| 4 | |||
| 5 | use ControleOnline\Entity\Device; |
||
| 6 | use ControleOnline\Entity\DeviceConfig; |
||
| 7 | use ControleOnline\Entity\People; |
||
|
0 ignored issues
–
show
|
|||
| 8 | use Doctrine\ORM\EntityManagerInterface; |
||
|
0 ignored issues
–
show
The type
Doctrine\ORM\EntityManagerInterface 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 Loading history...
|
|||
| 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 findDevices(array|string $devices) |
||
| 32 | { |
||
| 33 | return $this->manager->getRepository(Device::class)->findBy([ |
||
| 34 | 'device' => $devices |
||
| 35 | ]); |
||
| 36 | } |
||
| 37 | |||
| 38 | public function discoveryDevice($deviceId) |
||
| 39 | { |
||
| 40 | $device = $this->manager->getRepository(Device::class)->findOneBy([ |
||
| 41 | 'device' => $deviceId |
||
| 42 | ]); |
||
| 43 | if (!$device) { |
||
| 44 | $device = new Device(); |
||
| 45 | $device->setDevice($deviceId); |
||
| 46 | $this->manager->persist($device); |
||
| 47 | $this->manager->flush(); |
||
| 48 | } |
||
| 49 | return $device; |
||
| 50 | } |
||
| 51 | |||
| 52 | |||
| 53 | public function discoveryDeviceConfig(Device $device, People $people): DeviceConfig |
||
| 54 | { |
||
| 55 | $device_config = $this->manager->getRepository(DeviceConfig::class)->findOneBy([ |
||
| 56 | 'device' => $device, |
||
| 57 | 'people' => $people |
||
| 58 | ]); |
||
| 59 | if (!$device_config) { |
||
| 60 | $device_config = new DeviceConfig(); |
||
| 61 | $device_config->setDevice($device); |
||
| 62 | $device_config->setPeople($people); |
||
| 63 | $this->manager->persist($device_config); |
||
| 64 | } |
||
| 65 | |||
| 66 | return $device_config; |
||
| 67 | } |
||
| 68 | |||
| 69 | public function addDeviceConfigs(People $people, array $configs, $deviceId) |
||
| 70 | { |
||
| 71 | $device = $this->discoveryDevice($deviceId); |
||
| 72 | |||
| 73 | $device_config = $this->discoveryDeviceConfig($device, $people); |
||
| 74 | foreach ($configs as $key => $config) |
||
| 75 | $device_config->addConfig($key, $config); |
||
| 76 | |||
| 77 | $this->manager->persist($device_config); |
||
| 78 | $this->manager->flush(); |
||
| 79 | |||
| 80 | return $device_config; |
||
| 81 | } |
||
| 82 | } |
||
| 83 |
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