commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
ExtensionModel.php
1<?php
2
3declare(strict_types=1);
10
21use DateTimeImmutable;
22use stdClass;
23
27final class ExtensionModel extends JsonObjectModel implements Extension
28{
33 protected $id;
34
39 protected $version;
40
45 protected $createdAt;
46
51 protected $lastModifiedAt;
52
57 protected $lastModifiedBy;
58
63 protected $createdBy;
64
69 protected $key;
70
75 protected $destination;
76
81 protected $triggers;
82
87 protected $timeoutInMs;
88
93 protected $dependencies;
94
99 protected $expansionPaths;
100
106
107
111 public function __construct(
112 ?string $id = null,
113 ?int $version = null,
114 ?DateTimeImmutable $createdAt = null,
115 ?DateTimeImmutable $lastModifiedAt = null,
117 ?CreatedBy $createdBy = null,
118 ?string $key = null,
121 ?int $timeoutInMs = null,
123 ?array $expansionPaths = null,
125 ) {
126 $this->id = $id;
127 $this->version = $version;
128 $this->createdAt = $createdAt;
129 $this->lastModifiedAt = $lastModifiedAt;
130 $this->lastModifiedBy = $lastModifiedBy;
131 $this->createdBy = $createdBy;
132 $this->key = $key;
133 $this->destination = $destination;
134 $this->triggers = $triggers;
135 $this->timeoutInMs = $timeoutInMs;
136 $this->dependencies = $dependencies;
137 $this->expansionPaths = $expansionPaths;
138 $this->additionalContext = $additionalContext;
139 }
140
147 public function getId()
148 {
149 if (is_null($this->id)) {
151 $data = $this->raw(self::FIELD_ID);
152 if (is_null($data)) {
153 return null;
154 }
155 $this->id = (string) $data;
156 }
157
158 return $this->id;
159 }
160
167 public function getVersion()
168 {
169 if (is_null($this->version)) {
171 $data = $this->raw(self::FIELD_VERSION);
172 if (is_null($data)) {
173 return null;
174 }
175 $this->version = (int) $data;
176 }
177
178 return $this->version;
179 }
180
187 public function getCreatedAt()
188 {
189 if (is_null($this->createdAt)) {
191 $data = $this->raw(self::FIELD_CREATED_AT);
192 if (is_null($data)) {
193 return null;
194 }
195 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
196 if (false === $data) {
197 return null;
198 }
199 $this->createdAt = $data;
200 }
201
202 return $this->createdAt;
203 }
204
211 public function getLastModifiedAt()
212 {
213 if (is_null($this->lastModifiedAt)) {
215 $data = $this->raw(self::FIELD_LAST_MODIFIED_AT);
216 if (is_null($data)) {
217 return null;
218 }
219 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
220 if (false === $data) {
221 return null;
222 }
223 $this->lastModifiedAt = $data;
224 }
225
227 }
228
235 public function getLastModifiedBy()
236 {
237 if (is_null($this->lastModifiedBy)) {
239 $data = $this->raw(self::FIELD_LAST_MODIFIED_BY);
240 if (is_null($data)) {
241 return null;
242 }
243
244 $this->lastModifiedBy = LastModifiedByModel::of($data);
245 }
246
248 }
249
256 public function getCreatedBy()
257 {
258 if (is_null($this->createdBy)) {
260 $data = $this->raw(self::FIELD_CREATED_BY);
261 if (is_null($data)) {
262 return null;
263 }
264
265 $this->createdBy = CreatedByModel::of($data);
266 }
267
268 return $this->createdBy;
269 }
270
277 public function getKey()
278 {
279 if (is_null($this->key)) {
281 $data = $this->raw(self::FIELD_KEY);
282 if (is_null($data)) {
283 return null;
284 }
285 $this->key = (string) $data;
286 }
287
288 return $this->key;
289 }
290
297 public function getDestination()
298 {
299 if (is_null($this->destination)) {
301 $data = $this->raw(self::FIELD_DESTINATION);
302 if (is_null($data)) {
303 return null;
304 }
306 $this->destination = $className::of($data);
307 }
308
309 return $this->destination;
310 }
311
318 public function getTriggers()
319 {
320 if (is_null($this->triggers)) {
322 $data = $this->raw(self::FIELD_TRIGGERS);
323 if (is_null($data)) {
324 return null;
325 }
326 $this->triggers = ExtensionTriggerCollection::fromArray($data);
327 }
328
329 return $this->triggers;
330 }
331
341 public function getTimeoutInMs()
342 {
343 if (is_null($this->timeoutInMs)) {
345 $data = $this->raw(self::FIELD_TIMEOUT_IN_MS);
346 if (is_null($data)) {
347 return null;
348 }
349 $this->timeoutInMs = (int) $data;
350 }
351
352 return $this->timeoutInMs;
353 }
354
361 public function getDependencies()
362 {
363 if (is_null($this->dependencies)) {
365 $data = $this->raw(self::FIELD_DEPENDENCIES);
366 if (is_null($data)) {
367 return null;
368 }
369 $this->dependencies = ExtensionReferenceCollection::fromArray($data);
370 }
371
372 return $this->dependencies;
373 }
374
382 public function getExpansionPaths()
383 {
384 if (is_null($this->expansionPaths)) {
386 $data = $this->raw(self::FIELD_EXPANSION_PATHS);
387 if (is_null($data)) {
388 return null;
389 }
390 $this->expansionPaths = $data;
391 }
392
394 }
395
402 public function getAdditionalContext()
403 {
404 if (is_null($this->additionalContext)) {
406 $data = $this->raw(self::FIELD_ADDITIONAL_CONTEXT);
407 if (is_null($data)) {
408 return null;
409 }
410
411 $this->additionalContext = ExtensionAdditionalContextModel::of($data);
412 }
413
415 }
416
417
421 public function setId(?string $id): void
422 {
423 $this->id = $id;
424 }
425
429 public function setVersion(?int $version): void
430 {
431 $this->version = $version;
432 }
433
437 public function setCreatedAt(?DateTimeImmutable $createdAt): void
438 {
439 $this->createdAt = $createdAt;
440 }
441
445 public function setLastModifiedAt(?DateTimeImmutable $lastModifiedAt): void
446 {
447 $this->lastModifiedAt = $lastModifiedAt;
448 }
449
454 {
455 $this->lastModifiedBy = $lastModifiedBy;
456 }
457
461 public function setCreatedBy(?CreatedBy $createdBy): void
462 {
463 $this->createdBy = $createdBy;
464 }
465
469 public function setKey(?string $key): void
470 {
471 $this->key = $key;
472 }
473
478 {
479 $this->destination = $destination;
480 }
481
486 {
487 $this->triggers = $triggers;
488 }
489
493 public function setTimeoutInMs(?int $timeoutInMs): void
494 {
495 $this->timeoutInMs = $timeoutInMs;
496 }
497
502 {
503 $this->dependencies = $dependencies;
504 }
505
509 public function setExpansionPaths(?array $expansionPaths): void
510 {
511 $this->expansionPaths = $expansionPaths;
512 }
513
518 {
519 $this->additionalContext = $additionalContext;
520 }
521
522
523 #[\ReturnTypeWillChange]
524 public function jsonSerialize()
525 {
526 $data = $this->toArray();
527 if (isset($data[Extension::FIELD_CREATED_AT]) && $data[Extension::FIELD_CREATED_AT] instanceof \DateTimeImmutable) {
528 $data[Extension::FIELD_CREATED_AT] = $data[Extension::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
529 }
530
531 if (isset($data[Extension::FIELD_LAST_MODIFIED_AT]) && $data[Extension::FIELD_LAST_MODIFIED_AT] instanceof \DateTimeImmutable) {
532 $data[Extension::FIELD_LAST_MODIFIED_AT] = $data[Extension::FIELD_LAST_MODIFIED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
533 }
534 return (object) $data;
535 }
536}
__construct(?string $id=null, ?int $version=null, ?DateTimeImmutable $createdAt=null, ?DateTimeImmutable $lastModifiedAt=null, ?LastModifiedBy $lastModifiedBy=null, ?CreatedBy $createdBy=null, ?string $key=null, ?ExtensionDestination $destination=null, ?ExtensionTriggerCollection $triggers=null, ?int $timeoutInMs=null, ?ExtensionReferenceCollection $dependencies=null, ?array $expansionPaths=null, ?ExtensionAdditionalContext $additionalContext=null)
setTriggers(?ExtensionTriggerCollection $triggers)
setDestination(?ExtensionDestination $destination)
setLastModifiedBy(?LastModifiedBy $lastModifiedBy)
setLastModifiedAt(?DateTimeImmutable $lastModifiedAt)
setAdditionalContext(?ExtensionAdditionalContext $additionalContext)
setDependencies(?ExtensionReferenceCollection $dependencies)
static fromArray(array $data)