Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
linkurl.php
1<?php
2namespace Bitrix\Im\Model;
3
7use Bitrix\Main\ORM\Data\Internal\DeleteByFilterTrait;
20
52{
53 use DeleteByFilterTrait {
54 deleteByFilter as defaultDeleteByFilter;
55 }
56
62 public static function getTableName()
63 {
64 return 'b_im_link_url';
65 }
66
72 public static function getMap()
73 {
74 return [
75 'ID' => new IntegerField(
76 'ID',
77 [
78 'primary' => true,
79 'autocomplete' => true,
80 ]
81 ),
82 'MESSAGE_ID' => new IntegerField(
83 'MESSAGE_ID',
84 []
85 ),
86 'CHAT_ID' => new IntegerField(
87 'CHAT_ID',
88 []
89 ),
90 'URL' => new StringField(
91 'URL',
92 [
93 'validation' => [__CLASS__, 'validateUrl'],
94 ]
95 ),
96 'PREVIEW_URL_ID' => new IntegerField(
97 'PREVIEW_URL_ID',
98 []
99 ),
100 'DATE_CREATE' => new DatetimeField(
101 'DATE_CREATE',
102 [
103 'required' => true,
104 'default_value' => static function() {
105 return new DateTime();
106 }
107 ]
108 ),
109 'AUTHOR_ID' => new IntegerField(
110 'AUTHOR_ID',
111 []
112 ),
113 'IS_INDEXED' => new BooleanField(
114 'IS_INDEXED',
115 [
116 'required' => true,
117 'values' => array('N', 'Y'),
118 'default' => 'N',
119 'default_value' => false,
120 ]
121 ),
122 'PREVIEW_URL' => (new Reference(
123 'PREVIEW_URL',
124 UrlMetadataTable::class,
125 Join::on('this.PREVIEW_URL_ID', 'ref.ID')
126 ))->configureJoinType(Join::TYPE_LEFT),
127 'MESSAGE' => (new Reference(
128 'MESSAGE',
129 MessageTable::class,
130 Join::on('this.MESSAGE_ID', 'ref.ID')
131 ))->configureJoinType(Join::TYPE_INNER),
132 'CHAT' => (new Reference(
133 'CHAT',
134 ChatTable::class,
135 Join::on('this.CHAT_ID', 'ref.ID')
136 ))->configureJoinType(Join::TYPE_INNER),
137 'AUTHOR' => (new Reference(
138 'AUTHOR',
139 \Bitrix\Main\UserTable::class,
140 Join::on('this.AUTHOR_ID', 'ref.ID')
141 ))->configureJoinType(Join::TYPE_INNER)
142 ];
143 }
144
150 public static function validateUrl(): array
151 {
152 return [
153 new LengthValidator(null, 2000),
154 ];
155 }
156
157 public static function deleteByFilter(array $filter)
158 {
159 LinkUrlIndexTable::deleteByFilter($filter);
160 static::defaultDeleteByFilter($filter);
161 }
162
163 public static function withSearchByUrl(Query $query, string $searchString): void
164 {
165 $preparedSearchString = LinkUrlIndexTable::prepareSearchString($searchString);
166 if (Content::canUseFulltextSearch($preparedSearchString))
167 {
168 $query->registerRuntimeField(
169 (new Reference(
170 'INDEX',
171 LinkUrlIndexTable::class,
172 Join::on('this.ID', 'ref.URL_ID')
173 ))->configureJoinType(Join::TYPE_INNER)
174 );
175
176 $query->whereMatch('INDEX.SEARCH_CONTENT', $preparedSearchString);
177 }
178 }
179}
registerRuntimeField($name, $fieldInfo=null)
Definition query.php:831