Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
barcodescanner.php
1
<?php
2
3
namespace
Bitrix\Catalog\Controller
;
4
5
use
Bitrix\Main\Error
;
6
use
Bitrix\Main\Loader
;
7
use
Bitrix\Main\Localization\Loc
;
8
use
Bitrix\Pull\Event
;
9
use
Bitrix\Catalog\Access\AccessController
;
10
use
Bitrix\Catalog\Access\ActionDictionary
;
11
12
final
class
BarcodeScanner
extends
\Bitrix\Main\Engine\Controller
13
{
18
public
function
sendMobilePushAction
(
string
$id): ?array
19
{
20
if
(!Loader::includeModule(
'catalog'
) || !AccessController::getCurrent()->check(ActionDictionary::ACTION_CATALOG_READ))
21
{
22
$this->
addError
(
new
Error
(
Loc::getMessage
(
'BARCODE_SCANNER_ACCESS_DENIED'
)));
23
return
null
;
24
}
25
26
if
(!Loader::includeModule(
'pull'
))
27
{
28
$this->
addError
(
new
Error
(
Loc::getMessage
(
'BARCODE_SCANNER_PULL_MODULE_REQUIRED'
)));
29
return
null
;
30
}
31
35
(new \CPushManager())->sendMessage([
36
[
37
'USER_ID'
=> $this->
getCurrentUser
()->getId(),
38
'APP_ID'
=>
'Bitrix24'
,
39
'EXPIRY'
=> 0,
40
'PARAMS'
=> [
41
'TYPE'
=>
'CATALOG_BARCODE_SCANNER'
,
42
'ID'
=> $id,
43
],
44
'ADVANCED_PARAMS'
=> [
45
'senderName'
=>
Loc::getMessage
(
'BARCODE_SCANNER_PUSH_TITLE'
),
46
'senderMessage'
=>
Loc::getMessage
(
'BARCODE_SCANNER_PUSH_TEXT'
)
47
]
48
]
49
]);
50
54
Event::add(
55
$this->
getCurrentUser
()->getId(),
56
[
57
'module_id'
=>
'catalog'
,
58
'command'
=>
'OpenBarcodeScanner'
,
59
'params'
=> [
60
'id'
=> $id,
61
]
62
]
63
);
64
65
return
[];
66
}
67
}
Bitrix\Catalog\Access\AccessController
Definition
AccessController.php:28
Bitrix\Catalog\Access\ActionDictionary
Definition
ActionDictionary.php:17
Bitrix\Catalog\Controller\BarcodeScanner
Definition
barcodescanner.php:13
Bitrix\Catalog\Controller\BarcodeScanner\sendMobilePushAction
sendMobilePushAction(string $id)
Definition
barcodescanner.php:18
Bitrix\Main\Engine\Controller
Definition
controller.php:32
Bitrix\Main\Engine\Controller\addError
addError(Error $error)
Definition
controller.php:1051
Bitrix\Main\Engine\Controller\getCurrentUser
getCurrentUser()
Definition
controller.php:264
Bitrix\Main\Error
Definition
error.php:14
Bitrix\Main\Event
Definition
event.php:5
Bitrix\Main\Loader
Definition
loader.php:12
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\getMessage
static getMessage($code, $replace=null, $language=null)
Definition
loc.php:29
Bitrix\Catalog\Controller
modules
catalog
lib
controller
barcodescanner.php
Создано системой
1.10.0