Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
senderinvitationfactory.php
1<?php
2
4
11
13{
14 private const TYPE_REQUEST = InvitationInfo::TYPE_REQUEST;
15 private const TYPE_CANCEL = InvitationInfo::TYPE_CANCEL;
16 private const TYPE_EDIT = InvitationInfo::TYPE_EDIT;
17
18 public function __construct(
19 private string $type,
20 private ?array $event,
21 private ?Context $context,
22 private int $counterInvitations
23 )
24 {
25 }
26
27 public function getInvitation(): ?SenderInvitation
28 {
29 if (is_null($this->event) || is_null($this->context))
30 {
31 return null;
32 }
33
35 $class = $this->getMap()[$this->type] ?? null;
36 if (is_null($class))
37 {
38 return null;
39 }
40
41 return $class::createInstance($this->event, $this->context)
42 ->setCounterInvitations($this->counterInvitations);
43 }
44
45 private function getMap(): array
46 {
47 return [
48 static::TYPE_REQUEST => SenderRequestInvitation::class,
49 static::TYPE_EDIT => SenderEditInvitation::class,
50 static::TYPE_CANCEL => SenderCancelInvitation::class,
51 ];
52 }
53}
__construct(private string $type, private ?array $event, private ?Context $context, private int $counterInvitations)