Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
handledmessagemapper.php
1
<?php
2
3
namespace
Bitrix\Calendar\Core\Queue\Message
;
4
5
use Bitrix\Calendar\Core;
6
use
Bitrix\Calendar\Core\Mappers\Mapper
;
7
use Bitrix\Calendar\Internals\EO_QueueHandledMessage;
8
use
Bitrix\Calendar\Internals\QueueHandledMessageTable
;
9
use
Bitrix\Main\ArgumentException
;
10
use
Bitrix\Main\ObjectException
;
11
use
Bitrix\Main\ObjectPropertyException
;
12
use
Bitrix\Main\ORM\Query\Result
;
13
use
Bitrix\Main\SystemException
;
14
use
Bitrix\Main\Type\DateTime
;
15
use Exception;
16
17
class
HandledMessageMapper
extends
Mapper
18
{
22
protected
function
getEntityClass
(): string
23
{
24
return
HandledMessage::class;
25
}
26
35
protected
function
getDataManagerResult
(array $params):
Result
36
{
37
$params[
'select'
] = $params[
'select'
] ?
38
array_merge($params[
'select'
], [
'MESSAGE'
])
39
: [
"*"
,
'MESSAGE'
];
40
$params[
'select'
] = array_unique($params[
'select'
]);
41
42
return
QueueHandledMessageTable::getList($params);
43
}
44
54
protected
function
getOneEntityByFilter
(array $filter): ?object
55
{
57
$data = $this->
getDataManagerResult
([
58
'filter'
=> $filter,
59
'select'
=> [
'*'
,
'MESSAGE'
],
60
'limit'
=> 1
61
])->fetchObject();
62
63
if
($data)
64
{
65
return
$this->
convertToObject
($data);
66
}
67
68
return
null
;
69
}
70
78
protected
function
convertToObject
($objectEO): ?Core\Base\
EntityInterface
79
{
80
return
(
new
BuilderHandledMessageFromDataManager
($objectEO))->build();
81
}
82
86
protected
function
getEntityName
(): string
87
{
88
return
'handledQueueMessage'
;
89
}
90
100
protected
function
createEntity
($entity, array $params = []): ?Core\Base\
EntityInterface
101
{
102
$data = $this->convertToArray($entity);
103
$data[
'DATE_CREATE'
] =
new
DateTime
();
104
$result = QueueHandledMessageTable::add($data);
105
if
($result->isSuccess())
106
{
107
return
$entity->setId($result->getId());
108
}
109
110
throw
new
Core\Base\BaseException
(
'Error of create Queue handled message'
, 400);
111
}
112
121
protected
function
updateEntity
($entity, array $params = []): ?Core\Base\
EntityInterface
122
{
123
$data = $this->convertToArray($entity);
124
$result = QueueHandledMessageTable::update($entity->getId(), $data);
125
if
($result->isSuccess())
126
{
127
return
$entity;
128
}
129
130
throw
new
Core\Base\BaseException
(
'Error of update Queue handled message'
, 400);
131
132
}
133
142
protected
function
deleteEntity
(Core\Base\
EntityInterface
$entity, array $params): ?Core\Base\
EntityInterface
143
{
144
145
$result = QueueHandledMessageTable::delete($entity->getId());
146
if
($result->isSuccess())
147
{
148
return
null
;
149
}
150
151
throw
new
Core\Base\BaseException
(
'Error of delete Queue handled message'
);
152
}
153
159
private
function
convertToArray(
HandledMessage
$entity): array
160
{
161
return
[
162
'MESSAGE_ID'
=> $entity->
getMessage
()->getId(),
163
'QUEUE_ID'
=> $entity->
getQueue
()->getQueueId(),
164
'HASH'
=> $entity->
getHash
(),
165
];
166
}
167
}
Bitrix\Calendar\Core\Base\BaseException
Definition
baseexception.php:8
Bitrix\Calendar\Core\Mappers\Mapper
Definition
mapper.php:12
Bitrix\Calendar\Core\Mappers\Mapper\getOneEntityByFilter
getOneEntityByFilter(array $filter)
Bitrix\Calendar\Core\Queue\Message\BuilderHandledMessageFromDataManager
Definition
builderhandledmessagefromdatamanager.php:12
Bitrix\Calendar\Core\Queue\Message\HandledMessage
Definition
handledmessage.php:10
Bitrix\Calendar\Core\Queue\Message\HandledMessage\getMessage
getMessage()
Definition
handledmessage.php:24
Bitrix\Calendar\Core\Queue\Message\HandledMessage\getHash
getHash()
Definition
handledmessage.php:60
Bitrix\Calendar\Core\Queue\Message\HandledMessage\getQueue
getQueue()
Definition
handledmessage.php:42
Bitrix\Calendar\Core\Queue\Message\HandledMessageMapper
Definition
handledmessagemapper.php:18
Bitrix\Calendar\Core\Queue\Message\HandledMessageMapper\convertToObject
convertToObject($objectEO)
Definition
handledmessagemapper.php:78
Bitrix\Calendar\Core\Queue\Message\HandledMessageMapper\updateEntity
updateEntity($entity, array $params=[])
Definition
handledmessagemapper.php:121
Bitrix\Calendar\Core\Queue\Message\HandledMessageMapper\getEntityName
getEntityName()
Definition
handledmessagemapper.php:86
Bitrix\Calendar\Core\Queue\Message\HandledMessageMapper\getEntityClass
getEntityClass()
Definition
handledmessagemapper.php:22
Bitrix\Calendar\Core\Queue\Message\HandledMessageMapper\deleteEntity
deleteEntity(Core\Base\EntityInterface $entity, array $params)
Definition
handledmessagemapper.php:142
Bitrix\Calendar\Core\Queue\Message\HandledMessageMapper\createEntity
createEntity($entity, array $params=[])
Definition
handledmessagemapper.php:100
Bitrix\Calendar\Core\Queue\Message\HandledMessageMapper\getDataManagerResult
getDataManagerResult(array $params)
Definition
handledmessagemapper.php:35
Bitrix\Calendar\Internals\QueueHandledMessageTable
Definition
queuehandledmessagetable.php:32
Bitrix\Main\ArgumentException
Definition
exception.php:34
Bitrix\Main\ORM\Data\Result
Definition
result.php:16
Bitrix\Main\ORM\Query\Result
Definition
result.php:34
Bitrix\Main\ObjectException
Definition
exception.php:192
Bitrix\Main\ObjectPropertyException
Definition
exception.php:181
Bitrix\Main\SystemException
Definition
exception.php:8
Bitrix\Main\Type\DateTime
Definition
datetime.php:9
Bitrix\Calendar\Core\Base\EntityInterface
Definition
entityinterface.php:6
Bitrix\Calendar\Core\Queue\Message
Definition
builderhandledmessagefromdatamanager.php:3
modules
calendar
lib
core
queue
message
handledmessagemapper.php
Создано системой
1.10.0