1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
barcodegenerator.php
См. документацию.
1
<?php
2
3
namespace
Bitrix\Sale\PaySystem;
4
5
use Bitrix\Main\Loader;
6
use Bitrix\UI\Barcode\Barcode;
7
use Bitrix\UI\Barcode\BarcodeDictionary;
8
9
class
BarcodeGenerator
10
{
11
private
Barcode
$barcode;
12
13
private
const
DEFAULT_W = 380;
14
private
const
DEFAULT_H = 380;
15
private
const
DEFAULT_P = 0;
16
private
const
DEFAULT_WQ = 0;
17
18
public
function
__construct
(?
array
$options
=
null
)
19
{
20
if
($this->includeUiModule())
21
{
22
$this->createBarcode(
$options
);
23
}
24
}
25
26
private
function
createBarcode(?
array
$options
=
null
): void
27
{
28
$options
=
29
is_null(
$options
)
30
? [
31
'w'
=> self::DEFAULT_W,
32
'h'
=> self::DEFAULT_H,
33
'p'
=> self::DEFAULT_P,
34
'wq'
=> self::DEFAULT_WQ,
35
]
36
: array_intersect_key(
$options
, array_flip(self::getAllowedOptions()))
37
;
38
39
$this->barcode =
new
Barcode
();
40
$this->barcode
41
->type(
BarcodeDictionary::TYPE_QR
)
42
->format(
BarcodeDictionary::FORMAT_PNG
)
43
->options(
$options
)
44
;
45
}
46
47
private
static
function
getAllowedOptions():
array
48
{
49
return
[
50
'w'
,
51
'h'
,
52
'p'
,
53
'wq'
,
54
];
55
}
56
57
public
function
generate
(
string
$data
): ?string
58
{
59
$renderData =
null
;
60
61
if
($this->includeUiModule())
62
{
63
$renderData = $this->barcode->render(
$data
);
64
}
65
66
return
$renderData ?:
null
;
67
}
68
69
private
function
includeUiModule(): bool
70
{
71
return
Loader::includeModule(
'ui'
);
72
}
73
}
Bitrix\Sale\PaySystem\BarcodeGenerator
Определения
barcodegenerator.php:10
Bitrix\Sale\PaySystem\BarcodeGenerator\__construct
__construct(?array $options=null)
Определения
barcodegenerator.php:18
Bitrix\Sale\PaySystem\BarcodeGenerator\generate
generate(string $data)
Определения
barcodegenerator.php:57
Bitrix\UI\Barcode\BarcodeDictionary\FORMAT_PNG
const FORMAT_PNG
Определения
barcodedictionary.php:13
Bitrix\UI\Barcode\BarcodeDictionary\TYPE_QR
const TYPE_QR
Определения
barcodedictionary.php:32
Bitrix\UI\Barcode\Barcode
Определения
barcode.php:15
$options
$options
Определения
commerceml2.php:49
$data
$data['IS_AVAILABLE']
Определения
.description.php:13
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
bitrix
modules
sale
lib
paysystem
barcodegenerator.php
Создано системой
1.14.0