commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
lib
commercetools-api
src
Models
Event
BaseEventModel.php
1
<?php
2
3
declare(strict_types=1);
9
namespace
Commercetools\Api\Models\Event
;
10
11
use
Commercetools\Base\DateTimeImmutableCollection
;
12
use
Commercetools\Base\JsonObject
;
13
use
Commercetools\Base\JsonObjectModel
;
14
use
Commercetools\Base\MapperFactory
;
15
use DateTimeImmutable;
16
use stdClass;
17
21
final
class
BaseEventModel
extends
JsonObjectModel
implements
BaseEvent
22
{
27
protected
$id
;
28
33
protected
$notificationType
;
34
39
protected
$resourceType
;
40
45
protected
$type
;
46
51
protected
$data
;
52
57
protected
$createdAt
;
58
59
63
public
function
__construct
(
64
?
string
$id
=
null
,
65
?
string
$notificationType
=
null
,
66
?
string
$resourceType
=
null
,
67
?
string
$type
=
null
,
68
?
JsonObject
$data
=
null
,
69
?DateTimeImmutable
$createdAt
=
null
70
) {
71
$this->
id
=
$id
;
72
$this->notificationType =
$notificationType
;
73
$this->resourceType =
$resourceType
;
74
$this->type =
$type
;
75
$this->data =
$data
;
76
$this->createdAt =
$createdAt
;
77
}
78
85
public
function
getId
()
86
{
87
if
(is_null($this->
id
)) {
89
$data
= $this->
raw
(self::FIELD_ID);
90
if
(is_null(
$data
)) {
91
return
null
;
92
}
93
$this->
id
= (string)
$data
;
94
}
95
96
return
$this->id
;
97
}
98
103
public
function
getNotificationType
()
104
{
105
if
(is_null($this->notificationType)) {
107
$data
= $this->
raw
(self::FIELD_NOTIFICATION_TYPE);
108
if
(is_null(
$data
)) {
109
return
null
;
110
}
111
$this->notificationType = (string)
$data
;
112
}
113
114
return
$this->notificationType
;
115
}
116
123
public
function
getResourceType
()
124
{
125
if
(is_null($this->resourceType)) {
127
$data
= $this->
raw
(self::FIELD_RESOURCE_TYPE);
128
if
(is_null(
$data
)) {
129
return
null
;
130
}
131
$this->resourceType = (string)
$data
;
132
}
133
134
return
$this->resourceType
;
135
}
136
143
public
function
getType
()
144
{
145
if
(is_null($this->type)) {
147
$data
= $this->
raw
(self::FIELD_TYPE);
148
if
(is_null(
$data
)) {
149
return
null
;
150
}
151
$this->type = (string)
$data
;
152
}
153
154
return
$this->type
;
155
}
156
163
public
function
getData
()
164
{
165
if
(is_null($this->data)) {
167
$data
= $this->
raw
(self::FIELD_DATA);
168
if
(is_null(
$data
)) {
169
return
null
;
170
}
171
$this->data = JsonObjectModel::of(
$data
);
172
}
173
174
return
$this->data
;
175
}
176
183
public
function
getCreatedAt
()
184
{
185
if
(is_null($this->createdAt)) {
187
$data
= $this->
raw
(self::FIELD_CREATED_AT);
188
if
(is_null(
$data
)) {
189
return
null
;
190
}
191
$data
= DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT,
$data
);
192
if
(
false
===
$data
) {
193
return
null
;
194
}
195
$this->createdAt =
$data
;
196
}
197
198
return
$this->createdAt
;
199
}
200
201
205
public
function
setId
(?
string
$id
): void
206
{
207
$this->
id
=
$id
;
208
}
209
213
public
function
setNotificationType
(?
string
$notificationType
): void
214
{
215
$this->notificationType =
$notificationType
;
216
}
217
221
public
function
setResourceType
(?
string
$resourceType
): void
222
{
223
$this->resourceType =
$resourceType
;
224
}
225
229
public
function
setType
(?
string
$type
): void
230
{
231
$this->type =
$type
;
232
}
233
237
public
function
setData
(?
JsonObject
$data
): void
238
{
239
$this->data =
$data
;
240
}
241
245
public
function
setCreatedAt
(?DateTimeImmutable
$createdAt
): void
246
{
247
$this->createdAt =
$createdAt
;
248
}
249
250
251
#[\ReturnTypeWillChange]
252
public
function
jsonSerialize
()
253
{
254
$data
= $this->
toArray
();
255
if
(isset(
$data
[
BaseEvent::FIELD_CREATED_AT
]) &&
$data
[
BaseEvent::FIELD_CREATED_AT
] instanceof \DateTimeImmutable) {
256
$data
[
BaseEvent::FIELD_CREATED_AT
] =
$data
[
BaseEvent::FIELD_CREATED_AT
]->setTimeZone(
new
\DateTimeZone(
'UTC'
))->format(
'c'
);
257
}
258
return
(
object
)
$data
;
259
}
260
}
Commercetools\Api\Models\Event\BaseEventModel
Definition
BaseEventModel.php:22
Commercetools\Api\Models\Event\BaseEventModel\setCreatedAt
setCreatedAt(?DateTimeImmutable $createdAt)
Definition
BaseEventModel.php:245
Commercetools\Api\Models\Event\BaseEventModel\$id
$id
Definition
BaseEventModel.php:27
Commercetools\Api\Models\Event\BaseEventModel\setNotificationType
setNotificationType(?string $notificationType)
Definition
BaseEventModel.php:213
Commercetools\Api\Models\Event\BaseEventModel\__construct
__construct(?string $id=null, ?string $notificationType=null, ?string $resourceType=null, ?string $type=null, ?JsonObject $data=null, ?DateTimeImmutable $createdAt=null)
Definition
BaseEventModel.php:63
Commercetools\Api\Models\Event\BaseEventModel\setId
setId(?string $id)
Definition
BaseEventModel.php:205
Commercetools\Api\Models\Event\BaseEventModel\setData
setData(?JsonObject $data)
Definition
BaseEventModel.php:237
Commercetools\Api\Models\Event\BaseEventModel\$data
$data
Definition
BaseEventModel.php:51
Commercetools\Api\Models\Event\BaseEventModel\getId
getId()
Definition
BaseEventModel.php:85
Commercetools\Api\Models\Event\BaseEventModel\$type
$type
Definition
BaseEventModel.php:45
Commercetools\Api\Models\Event\BaseEventModel\setResourceType
setResourceType(?string $resourceType)
Definition
BaseEventModel.php:221
Commercetools\Api\Models\Event\BaseEventModel\getNotificationType
getNotificationType()
Definition
BaseEventModel.php:103
Commercetools\Api\Models\Event\BaseEventModel\$notificationType
$notificationType
Definition
BaseEventModel.php:33
Commercetools\Api\Models\Event\BaseEventModel\getType
getType()
Definition
BaseEventModel.php:143
Commercetools\Api\Models\Event\BaseEventModel\getResourceType
getResourceType()
Definition
BaseEventModel.php:123
Commercetools\Api\Models\Event\BaseEventModel\$resourceType
$resourceType
Definition
BaseEventModel.php:39
Commercetools\Api\Models\Event\BaseEventModel\getData
getData()
Definition
BaseEventModel.php:163
Commercetools\Api\Models\Event\BaseEventModel\jsonSerialize
jsonSerialize()
Definition
BaseEventModel.php:252
Commercetools\Api\Models\Event\BaseEventModel\getCreatedAt
getCreatedAt()
Definition
BaseEventModel.php:183
Commercetools\Api\Models\Event\BaseEventModel\$createdAt
$createdAt
Definition
BaseEventModel.php:57
Commercetools\Api\Models\Event\BaseEventModel\setType
setType(?string $type)
Definition
BaseEventModel.php:229
Commercetools\Base\BaseJsonObject\raw
raw(string $field)
Definition
BaseJsonObject.php:57
Commercetools\Base\DateTimeImmutableCollection
Definition
DateTimeImmutableCollection.php:21
Commercetools\Base\JsonObjectModel
Definition
JsonObjectModel.php:15
Commercetools\Base\JsonObjectModel\toArray
toArray()
Definition
JsonObjectModel.php:32
Commercetools\Base\MapperFactory
Definition
MapperFactory.php:16
Commercetools\Api\Models\Event\BaseEvent
Definition
BaseEvent.php:16
Commercetools\Api\Models\Event\BaseEvent\FIELD_CREATED_AT
const FIELD_CREATED_AT
Definition
BaseEvent.php:22
Commercetools\Base\JsonObject
Definition
JsonObject.php:15
Commercetools\Api\Models\Event
Definition
BaseEvent.php:9
Generated by
1.9.8