Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
linkcalendar.php
1<?php
2namespace Bitrix\Im\Model;
3
5use Bitrix\Main\ORM\Data\Internal\DeleteByFilterTrait;
15
49{
50 use DeleteByFilterTrait {
51 deleteByFilter as defaultDeleteByFilter;
52 }
53
59 public static function getTableName()
60 {
61 return 'b_im_link_calendar';
62 }
63
69 public static function getMap()
70 {
71 return [
72 'ID' => new IntegerField(
73 'ID',
74 [
75 'primary' => true,
76 'autocomplete' => true,
77 ]
78 ),
79 'MESSAGE_ID' => new IntegerField(
80 'MESSAGE_ID',
81 [
82 'nullable' => true
83 ]
84 ),
85 'CHAT_ID' => new IntegerField(
86 'CHAT_ID',
87 [
88 ]
89 ),
90 'AUTHOR_ID' => new IntegerField(
91 'AUTHOR_ID',
92 [
93 ]
94 ),
95 'DATE_CREATE' => new DatetimeField(
96 'DATE_CREATE',
97 [
98 'required' => true,
99 'default_value' => static function() {
100 return new DateTime();
101 }
102 ]
103 ),
104 'CALENDAR_ID' => new IntegerField(
105 'CALENDAR_ID',
106 [
107 ]
108 ),
109 'CALENDAR_TITLE' => new StringField(
110 'CALENDAR_TITLE',
111 [
112 'validation' => [__CLASS__, 'validateCalendarTitle'],
113 ]
114 ),
115 'CALENDAR_DATE_FROM' => new DatetimeField(
116 'CALENDAR_DATE_FROM',
117 [
118 ]
119 ),
120 'CALENDAR_DATE_TO' => new DatetimeField(
121 'CALENDAR_DATE_TO',
122 [
123 ]
124 ),
125 'INDEX' => (new Reference(
126 'INDEX',
127 LinkCalendarIndexTable::class,
128 Join::on('this.ID', 'ref.ID')
129 ))->configureJoinType(Join::TYPE_INNER),
130 ];
131 }
132
138 public static function validateCalendarTitle(): array
139 {
140 return [
141 new LengthValidator(null, 255),
142 ];
143 }
144
145 public static function deleteByFilter(array $filter)
146 {
147 LinkCalendarIndexTable::deleteByFilter($filter);
148 static::defaultDeleteByFilter($filter);
149 }
150
151 public static function withSearchByTitle(Query $query, string $searchString): void
152 {
153 $preparedSearchString = LinkCalendarIndexTable::prepareSearchString($searchString);
154 if (Content::canUseFulltextSearch($preparedSearchString))
155 {
156 $query->registerRuntimeField(
157 (new Reference(
158 'INDEX',
159 LinkCalendarIndexTable::class,
160 Join::on('this.ID', 'ref.ID')
161 ))->configureJoinType(Join::TYPE_INNER)
162 );
163
164 $query->whereMatch('INDEX.SEARCH_CONTENT', $preparedSearchString);
165 }
166 }
167}
registerRuntimeField($name, $fieldInfo=null)
Definition query.php:831