Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
barcode.php
1
<?php
9
namespace
Bitrix\UI\Barcode
;
10
14
class
Barcode
15
{
16
private
$generator;
17
21
private
$type =
BarcodeDictionary::TYPE_QR
;
25
private
$format =
BarcodeDictionary::FORMAT_PNG
;
26
30
private
$options = [];
31
32
public
function
__construct
()
33
{
34
$this->generator =
new
BarcodeGenerator
();
35
}
36
41
public
function
render
(
string
$data)
42
{
43
if
($this->
format
===
BarcodeDictionary::FORMAT_SVG
)
44
{
45
return
$this->generator->render_svg($this->
type
, $data, $this->
options
);
46
}
47
48
$image = $this->generator->render_image($this->
type
, $data, $this->
options
);
49
50
ob_start();
51
switch
($this->
format
)
52
{
53
case
BarcodeDictionary::FORMAT_PNG
:
54
imagepng($image);
55
break
;
56
case
BarcodeDictionary::FORMAT_GIF
:
57
imagegif($image);
58
break
;
59
case
BarcodeDictionary::FORMAT_JPEG
:
60
imagejpeg($image);
61
break
;
62
}
63
imagedestroy($image);
64
65
return
ob_get_clean();
66
}
67
71
public
function
print
(
string
$data): void
72
{
73
$this->generator->output_image($this->
format
, $this->
type
, $data, $this->
options
);
74
}
75
80
public
function
type
(
string
$type): self
81
{
82
$this->
type
= $type;
83
return
$this;
84
}
85
90
public
function
format
(
string
$format): self
91
{
92
$this->
format
= $format;
93
return
$this;
94
}
95
100
public
function
options
(array $options): self
101
{
102
$this->
options
= $options;
103
return
$this;
104
}
105
111
public
function
option
(
string
$option, $value): self
112
{
113
$this->
options
[$option] = $value;
114
return
$this;
115
}
116
}
Bitrix\UI\Barcode\BarcodeDictionary\FORMAT_JPEG
const FORMAT_JPEG
Definition
barcodedictionary.php:15
Bitrix\UI\Barcode\BarcodeDictionary\FORMAT_SVG
const FORMAT_SVG
Definition
barcodedictionary.php:16
Bitrix\UI\Barcode\BarcodeDictionary\FORMAT_GIF
const FORMAT_GIF
Definition
barcodedictionary.php:14
Bitrix\UI\Barcode\BarcodeDictionary\FORMAT_PNG
const FORMAT_PNG
Definition
barcodedictionary.php:13
Bitrix\UI\Barcode\BarcodeDictionary\TYPE_QR
const TYPE_QR
Definition
barcodedictionary.php:32
Bitrix\UI\Barcode\BarcodeGenerator
Definition
barcodegenerator.php:33
Bitrix\UI\Barcode\Barcode
Definition
barcode.php:15
Bitrix\UI\Barcode\Barcode\__construct
__construct()
Definition
barcode.php:32
Bitrix\UI\Barcode\Barcode\render
render(string $data)
Definition
barcode.php:41
Bitrix\UI\Barcode\Barcode\print
print(string $data)
Definition
barcode.php:71
Bitrix\UI\Barcode\Barcode\format
format(string $format)
Definition
barcode.php:90
Bitrix\UI\Barcode\Barcode\type
type(string $type)
Definition
barcode.php:80
Bitrix\UI\Barcode\Barcode\options
options(array $options)
Definition
barcode.php:100
Bitrix\UI\Barcode\Barcode\option
option(string $option, $value)
Definition
barcode.php:111
Bitrix\UI\Barcode
Definition
barcode.php:9
modules
ui
lib
barcode
barcode.php
Создано системой
1.10.0