Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
linkurl.php
1
<?php
2
namespace
Bitrix\Im\Model
;
3
4
use
Bitrix\Im\Model\ChatTable
;
5
use
Bitrix\Im\Model\MessageTable
;
6
use
Bitrix\Main\ORM\Data\DataManager
;
7
use Bitrix\Main\ORM\Data\Internal\DeleteByFilterTrait;
8
use
Bitrix\Main\ORM\Fields\BooleanField
;
9
use
Bitrix\Main\ORM\Fields\DatetimeField
;
10
use
Bitrix\Main\ORM\Fields\IntegerField
;
11
use
Bitrix\Main\ORM\Fields\Relations\Reference
;
12
use
Bitrix\Main\ORM\Fields\StringField
;
13
use
Bitrix\Main\ORM\Fields\TextField
;
14
use
Bitrix\Main\ORM\Fields\Validators\LengthValidator
;
15
use
Bitrix\Main\ORM\Query\Join
;
16
use
Bitrix\Main\ORM\Query\Query
;
17
use
Bitrix\Main\Search\Content
;
18
use
Bitrix\Main\Type\DateTime
;
19
use
Bitrix\Main\UrlPreview\UrlMetadataTable
;
20
51
class
LinkUrlTable
extends
DataManager
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
}
Bitrix\Im\Internals\Query
Definition
query.php:10
Bitrix\Im\Model\ChatTable
Definition
chat.php:55
Bitrix\Im\Model\LinkUrlTable
Definition
linkurl.php:52
Bitrix\Im\Model\LinkUrlTable\validateUrl
static validateUrl()
Definition
linkurl.php:150
Bitrix\Im\Model\LinkUrlTable\getMap
static getMap()
Definition
linkurl.php:72
Bitrix\Im\Model\LinkUrlTable\deleteByFilter
static deleteByFilter(array $filter)
Definition
linkurl.php:157
Bitrix\Im\Model\LinkUrlTable\withSearchByUrl
static withSearchByUrl(Query $query, string $searchString)
Definition
linkurl.php:163
Bitrix\Im\Model\LinkUrlTable\getTableName
static getTableName()
Definition
linkurl.php:62
Bitrix\Im\Model\MessageTable
Definition
message.php:50
Bitrix\Main\ORM\Data\DataManager
Definition
datamanager.php:33
Bitrix\Main\ORM\Fields\BooleanField
Definition
booleanfield.php:20
Bitrix\Main\ORM\Fields\DatetimeField
Definition
datetimefield.php:22
Bitrix\Main\ORM\Fields\IntegerField
Definition
integerfield.php:20
Bitrix\Main\ORM\Fields\Relations\Reference
Definition
reference.php:26
Bitrix\Main\ORM\Fields\StringField
Definition
stringfield.php:20
Bitrix\Main\ORM\Fields\TextField
Definition
textfield.php:20
Bitrix\Main\ORM\Fields\Validators\LengthValidator
Definition
lengthvalidator.php:19
Bitrix\Main\ORM\Query\Join
Definition
join.php:19
Bitrix\Main\ORM\Query\Query
Definition
query.php:118
Bitrix\Main\ORM\Query\Query\registerRuntimeField
registerRuntimeField($name, $fieldInfo=null)
Definition
query.php:831
Bitrix\Main\Search\Content
Definition
content.php:8
Bitrix\Main\Type\DateTime
Definition
datetime.php:9
Bitrix\Main\UrlPreview\UrlMetadataTable
Definition
urlmetadata.php:27
Bitrix\Im\Model
Definition
alias.php:2
Bitrix
modules
im
lib
model
linkurl.php
Создано системой
1.10.0