Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
type.php
1<?php
2namespace Bitrix\Iblock;
3
7
8Loc::loadMessages(__FILE__);
39{
45 public static function getTableName()
46 {
47 return 'b_iblock_type';
48 }
49
55 public static function getMap()
56 {
57 return array(
58 'ID' => array(
59 'data_type' => 'string',
60 'primary' => true,
61 'validation' => array(__CLASS__, 'validateId'),
62 'title' => Loc::getMessage('IBLOCK_TYPE_ENTITY_ID_FIELD'),
63 ),
64 'SECTIONS' => array(
65 'data_type' => 'boolean',
66 'values' => array('N','Y'),
67 'title' => Loc::getMessage('IBLOCK_TYPE_ENTITY_SECTIONS_FIELD'),
68 ),
69 'EDIT_FILE_BEFORE' => array(
70 'data_type' => 'string',
71 'validation' => array(__CLASS__, 'validateEditFileBefore'),
72 'title' => Loc::getMessage('IBLOCK_TYPE_ENTITY_EDIT_FILE_BEFORE_FIELD'),
73 ),
74 'EDIT_FILE_AFTER' => array(
75 'data_type' => 'string',
76 'validation' => array(__CLASS__, 'validateEditFileAfter'),
77 'title' => Loc::getMessage('IBLOCK_TYPE_ENTITY_EDIT_FILE_AFTER_FIELD'),
78 ),
79 'IN_RSS' => array(
80 'data_type' => 'boolean',
81 'values' => array('N','Y'),
82 'title' => Loc::getMessage('IBLOCK_TYPE_ENTITY_IN_RSS_FIELD'),
83 ),
84 'SORT' => array(
85 'data_type' => 'integer',
86 'title' => Loc::getMessage('IBLOCK_TYPE_ENTITY_SORT_FIELD'),
87 ),
88 'LANG_MESSAGE' => array(
89 'data_type' => 'Bitrix\Iblock\TypeLanguage',
90 'reference' => array('=this.ID' => 'ref.IBLOCK_TYPE_ID'),
91 ),
92 );
93 }
94
101 public static function validateId()
102 {
103 return array(
104 new ORM\Fields\Validators\LengthValidator(null, 50),
105 );
106 }
107
114 public static function validateEditFileBefore()
115 {
116 return array(
117 new ORM\Fields\Validators\LengthValidator(null, 255),
118 );
119 }
120
127 public static function validateEditFileAfter()
128 {
129 return array(
130 new ORM\Fields\Validators\LengthValidator(null, 255),
131 );
132 }
133
142 public static function onDelete(ORM\Event $event)
143 {
144 //TODO: need refactoring
145
146 $id = $event->getParameter("id");
147
148 //Delete information blocks
149 $iblockList = IblockTable::getList(array(
150 "select" => array("ID"),
151 "filter" => array(
152 "=IBLOCK_TYPE_ID" => $id["ID"],
153 ),
154 "order" => array("ID" => "DESC")
155 ));
156 while ($iblock = $iblockList->fetch())
157 {
158 $iblockDeleteResult = IblockTable::delete($iblock["ID"]);
159 if (!$iblockDeleteResult->isSuccess())
160 {
161 break;
162 }
163 }
164 unset($iblock);
165 unset($iblockList);
166
167 //Delete language messages
169 $result = TypeLanguageTable::deleteByIblockTypeId($id["ID"]);
170 }
171
172 public static function cleanCache(): void
173 {
174 parent::cleanCache();
175
176 $application = Main\Application::getInstance();
177 $managedCache = $application->getManagedCache();
178 $managedCache->cleanDir(self::getTableName());
179 unset($managedCache);
180 unset($application);
181 }
182}
static deleteByIblockTypeId($iblockTypeId)
static onDelete(ORM\Event $event)
Definition type.php:142
static validateEditFileAfter()
Definition type.php:127
static getTableName()
Definition type.php:45
static validateEditFileBefore()
Definition type.php:114
static loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29
static getList(array $parameters=array())