Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
action.php
1<?php
10
11abstract class Action
12{
13 const TYPE_EMAIL = 'email';
14 const TYPE_SMS = 'sms';
15
16 protected $type;
17 protected $recipient;
18 protected $text;
19
26 public function __construct($type, $recipient, $text)
27 {
28 $this->type = $type;
29 $this->recipient = $recipient;
30 $this->text = $text;
31 }
32
41 public static function createByType($type, $recipient, $text)
42 {
43 switch($type)
44 {
46 return new ActionEmail($recipient, $text);
47 case self::TYPE_SMS:
48 return new ActionSms($recipient, $text);
49 default:
50 throw new \Bitrix\Main\ArgumentException("Unknown action type", "type");
51 }
52 }
53
58 public function getType()
59 {
60 return $this->type;
61 }
62
67 public function getRecipient()
68 {
69 return $this->recipient;
70 }
71
76 public function getText()
77 {
78 return $this->text;
79 }
80
85 abstract public function send(Notification $notification);
86
87 protected static function getNotificationFields(Notification $notification)
88 {
89 return [
90 "NAME" => $notification->getName(),
91 "AUDIT_TYPE_ID" => $notification->getAuditTypeId(),
92 "ITEM_ID" => $notification->getItemId(),
93 "USER_ID" => $notification->getUserId(),
94 "REMOTE_ADDR" => $notification->getRemoteAddr(),
95 "USER_AGENT" => $notification->getUserAgent(),
96 "REQUEST_URI" => $notification->getRequestUri(),
97 "EVENT_COUNT" => $notification->getEventCount(),
98 ];
99 }
100}
__construct($type, $recipient, $text)
Definition action.php:26
static createByType($type, $recipient, $text)
Definition action.php:41
send(Notification $notification)
static getNotificationFields(Notification $notification)
Definition action.php:87