1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace ControleOnline\Service; |
4
|
|
|
|
5
|
|
|
use ControleOnline\Entity\Device; |
6
|
|
|
use ControleOnline\Entity\Spool; |
7
|
|
|
use Doctrine\ORM\EntityManagerInterface; |
|
|
|
|
8
|
|
|
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface |
|
|
|
|
9
|
|
|
as Security; |
10
|
|
|
|
11
|
|
|
class PrintService |
12
|
|
|
{ |
13
|
|
|
private $initialSpace = 8; |
14
|
|
|
private $totalChars = 48; |
15
|
|
|
private $text = ''; |
16
|
|
|
|
17
|
|
|
public function __construct( |
18
|
|
|
private EntityManagerInterface $entityManager, |
19
|
|
|
private FileService $fileService, |
20
|
|
|
private StatusService $statusService, |
21
|
|
|
private Security $security |
22
|
|
|
) {} |
23
|
|
|
|
24
|
|
|
public function addLine($prefix = '', $suffix = '', $delimiter = ' ') |
25
|
|
|
{ |
26
|
|
|
$initialSpace = str_repeat(" ", $this->initialSpace); |
27
|
|
|
$count = $this->totalChars - $this->initialSpace - strlen($prefix) - strlen($suffix); |
28
|
|
|
if ($count > 0) |
29
|
|
|
$delimiter = str_repeat($delimiter, $count); |
30
|
|
|
$this->text .= $initialSpace . $prefix . $delimiter . $suffix . "\n"; |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
public function generatePrintData(Device $device): Spool |
34
|
|
|
{ |
35
|
|
|
$content = [ |
36
|
|
|
"operation" => "PRINT_TEXT", |
37
|
|
|
"styles" => [[]], |
38
|
|
|
"value" => [$this->text] |
39
|
|
|
]; |
40
|
|
|
|
41
|
|
|
return $this->addToSpool($device, $content); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
public function addToSpool(Device $device, $content): Spool |
45
|
|
|
{ |
46
|
|
|
$user = $this->security->getToken()->getUser(); |
47
|
|
|
$status = $this->statusService->discoveryStatus('open', 'open', 'print'); |
48
|
|
|
$file = $this->fileService->addFile($user->getPeople(), $content, 'print', 'print', 'text', 'txt'); |
49
|
|
|
|
50
|
|
|
$spool = new Spool(); |
51
|
|
|
$spool->setDevice($device); |
52
|
|
|
$spool->setStatus($status); |
53
|
|
|
$spool->setFile($file); |
54
|
|
|
|
55
|
|
|
$this->entityManager->persist($spool); |
56
|
|
|
$this->entityManager->flush(); |
57
|
|
|
|
58
|
|
|
return $spool; |
59
|
|
|
} |
60
|
|
|
} |
61
|
|
|
|
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