1 | <?php |
||
2 | |||
3 | namespace ControleOnline\Service; |
||
4 | |||
5 | use ControleOnline\Entity\Device; |
||
6 | use ControleOnline\Entity\People; |
||
0 ignored issues
–
show
|
|||
7 | use ControleOnline\Entity\Spool; |
||
8 | use ControleOnline\Service\Client\WebsocketClient; |
||
0 ignored issues
–
show
The type
ControleOnline\Service\Client\WebsocketClient 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 ![]() |
|||
9 | 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 ![]() |
|||
10 | use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface |
||
0 ignored issues
–
show
The type
Symfony\Component\Securi...e\TokenStorageInterface 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 ![]() |
|||
11 | as Security; |
||
12 | |||
13 | class PrintService |
||
14 | { |
||
15 | private $initialSpace = 8; |
||
16 | private $totalChars = 48; |
||
17 | private $text = ''; |
||
18 | protected static $logger; |
||
19 | |||
20 | public function __construct( |
||
21 | private EntityManagerInterface $entityManager, |
||
22 | private LoggerService $loggerService, |
||
23 | private FileService $fileService, |
||
24 | private StatusService $statusService, |
||
25 | private DeviceService $deviceService, |
||
26 | private Security $security, |
||
27 | private WebsocketClient $websocketClient, |
||
28 | ) { |
||
29 | self::$logger = $loggerService->getLogger('print'); |
||
30 | } |
||
31 | |||
32 | public function addLine($prefix = '', $suffix = '', $delimiter = ' ') |
||
33 | { |
||
34 | $initialSpace = str_repeat(" ", $this->initialSpace); |
||
35 | $count = $this->totalChars - $this->initialSpace - strlen($prefix) - strlen($suffix); |
||
36 | if ($count > 0) |
||
37 | $delimiter = str_repeat($delimiter, $count); |
||
38 | $this->text .= $initialSpace . $prefix . $delimiter . $suffix . "\n"; |
||
39 | } |
||
40 | |||
41 | public function makePrintDone(Spool $spool): Spool |
||
42 | { |
||
43 | $status = $this->statusService->discoveryStatus('closed', 'done', 'print'); |
||
44 | $spool->setStatus($status); |
||
45 | $this->entityManager->persist($spool); |
||
46 | $this->entityManager->flush(); |
||
47 | return $spool; |
||
48 | } |
||
49 | |||
50 | public function generatePrintData(Device $device, People $provider, ?array $aditionalData = []): Spool |
||
51 | { |
||
52 | $printer = null; |
||
53 | $device_config = $this->deviceService->discoveryDeviceConfig($device, $provider)->getConfigs(true); |
||
54 | if (isset($device_config['printer'])) |
||
55 | $printer = $this->deviceService->discoveryDevice($device_config['printer']); |
||
56 | |||
57 | $content = [ |
||
58 | "operation" => "PRINT_TEXT", |
||
59 | "styles" => [[]], |
||
60 | "value" => [$this->text] |
||
61 | ]; |
||
62 | |||
63 | $printData = $this->addToSpool($printer ?: $device, json_encode($content), $aditionalData); |
||
64 | |||
65 | if ($printer != $device) |
||
66 | $x = ''; |
||
0 ignored issues
–
show
|
|||
67 | |||
68 | return $printData; |
||
69 | } |
||
70 | |||
71 | public function addToSpool(Device $printer, string $content, ?array $data = []): Spool |
||
72 | { |
||
73 | $user = $this->security->getToken()->getUser(); |
||
74 | $status = $this->statusService->discoveryStatus('open', 'open', 'print'); |
||
75 | $file = $this->fileService->addFile($user->getPeople(), $content, 'print', 'print', 'text', 'txt'); |
||
76 | self::$logger->error($printer->getDevice()); |
||
77 | self::$logger->error($printer->getId()); |
||
78 | |||
79 | $spool = new Spool(); |
||
80 | $spool->setDevice($printer); |
||
81 | $spool->setStatus($status); |
||
82 | $spool->setFile($file); |
||
83 | $spool->setUser($user); |
||
84 | $this->entityManager->persist($spool); |
||
85 | $this->entityManager->flush(); |
||
86 | |||
87 | $data["action"] = "print"; |
||
88 | $data["store"] = "print"; |
||
89 | |||
90 | |||
91 | $this->websocketClient->push($printer, json_encode($data)); |
||
92 | |||
93 | return $spool; |
||
94 | } |
||
95 | } |
||
96 |
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