Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
list.php
1<?php
8namespace Bitrix\Sender;
9
14
15Loc::loadMessages(__FILE__);
16
34{
40 public static function getTableName()
41 {
42 return 'b_sender_list';
43 }
44
50 public static function getMap()
51 {
52 return array(
53 'ID' => array(
54 'data_type' => 'integer',
55 'autocomplete' => true,
56 'primary' => true,
57 ),
58 'CODE' => array(
59 'data_type' => 'string',
60 'validation' => array(__CLASS__, 'validateCode'),
61 'title' => Loc::getMessage('SENDER_ENTITY_LIST_FIELD_TITLE_CODE'),
62 ),
63 'NAME' => array(
64 'data_type' => 'string',
65 'required' => true,
66 'default_value' => Loc::getMessage(
67 'SENDER_ENTITY_LIST_FIELD_NAME_PATTERN',
68 ['%date%' => Internals\PrettyDate::formatDate()]
69 ),
70 'title' => Loc::getMessage('SENDER_ENTITY_LIST_FIELD_TITLE_NAME'),
71 ),
72 'SORT' => array(
73 'data_type' => 'integer',
74 'default_value' => 100,
75 'required' => true,
76 'title' => Loc::getMessage('SENDER_ENTITY_LIST_FIELD_TITLE_SORT'),
77 ),
78 'CONTACT_LIST' => array(
79 'data_type' => 'Bitrix\Sender\ContactListTable',
80 'reference' => array('=this.ID' => 'ref.LIST_ID'),
81 ),
82 );
83 }
84
90 public static function validateCode()
91 {
92 return array(
93 new Entity\Validator\Length(null, 60),
94 );
95 }
96
103 public static function onAfterDelete(Entity\Event $event)
104 {
105 $result = new Entity\EventResult;
106 $data = $event->getParameters();
107
108 $primary = array('LIST_ID' => $data['primary']['ID']);
110
111 return $result;
112 }
113
122 public static function addIfNotExist($code, $name)
123 {
124 $id = false;
125 if( !($arList = static::getList(array('filter' => array('CODE' => $code)))->fetch() ))
126 {
127 $resultAdd = static::add(array('CODE' => $code, 'NAME' => $name));
128 if ($resultAdd->isSuccess())
129 {
130 $id = $resultAdd->getId();
131 }
132 }
133 else
134 {
135 $id = $arList['ID'];
136 }
137
138 return $id;
139 }
140}
static loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29
static deleteList(array $filter)
static addIfNotExist($code, $name)
Definition list.php:122
static onAfterDelete(Entity\Event $event)
Definition list.php:103
static getTableName()
Definition list.php:40
static validateCode()
Definition list.php:90