Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
filterentity.php
1
<?php
2
namespace
Bitrix\Landing\Internals
;
3
4
use
Bitrix\Main\Application
;
5
use
Bitrix\Main\Entity
;
6
use
Bitrix\Main\Localization\Loc
;
7
8
Loc::loadMessages
(__FILE__);
9
26
class
FilterEntityTable
extends
Entity\DataManager
27
{
32
public
static
function
getTableName
()
33
{
34
return
'b_landing_filter_entity'
;
35
}
36
41
public
static
function
getMap
()
42
{
43
return
array(
44
'ID'
=>
new
Entity
\
IntegerField
(
'ID'
, array(
45
'primary'
=>
true
,
46
'autocomplete'
=>
true
,
47
'title'
=>
'ID'
48
)),
49
'SOURCE_ID'
=>
new
Entity
\
StringField
(
'SOURCE_ID'
, array(
50
'title'
=>
Loc::getMessage
(
'LANDING_TABLE_FIELD_SOURCE_ID'
),
51
'required'
=>
true
52
)),
53
'FILTER_HASH'
=>
new
Entity
\
StringField
(
'FILTER_HASH'
, array(
54
'title'
=>
Loc::getMessage
(
'LANDING_TABLE_FIELD_FILTER_HASH'
),
55
'required'
=>
true
56
)),
57
'FILTER'
=>
new
Entity
\
StringField
(
'FILTER'
, array(
58
'title'
=>
Loc::getMessage
(
'LANDING_TABLE_FIELD_FILTER'
),
59
'serialized'
=>
true
,
60
'required'
=>
true
61
)),
62
'CREATED_BY_ID'
=>
new
Entity
\
IntegerField
(
'CREATED_BY_ID'
, array(
63
'title'
=>
Loc::getMessage
(
'LANDING_TABLE_FIELD_CREATED_BY_ID'
),
64
'required'
=>
true
65
)),
66
'MODIFIED_BY_ID'
=>
new
Entity
\
IntegerField
(
'MODIFIED_BY_ID'
, array(
67
'title'
=>
Loc::getMessage
(
'LANDING_TABLE_FIELD_MODIFIED_BY_ID'
),
68
'required'
=>
true
69
)),
70
'DATE_CREATE'
=>
new
Entity
\
DatetimeField
(
'DATE_CREATE'
, array(
71
'title'
=>
Loc::getMessage
(
'LANDING_TABLE_FIELD_DATE_CREATE'
),
72
'required'
=>
true
73
)),
74
'DATE_MODIFY'
=>
new
Entity
\
DatetimeField
(
'DATE_MODIFY'
, array(
75
'title'
=>
Loc::getMessage
(
'LANDING_TABLE_FIELD_DATE_MODIFY'
),
76
'required'
=>
true
77
))
78
);
79
}
80
87
public
static
function
applyBlock
($filterId, $blockId)
88
{
89
$res = FilterBlockTable::getList([
90
'select'
=> [
91
'ID'
92
],
93
'filter'
=> [
94
'FILTER_ID'
=> $filterId,
95
'BLOCK_ID'
=> $blockId
96
]
97
]);
98
if
(!$res->fetch())
99
{
100
FilterBlockTable::add([
101
'FILTER_ID'
=> $filterId,
102
'BLOCK_ID'
=> $blockId
103
]);
104
}
105
unset($res);
106
self::actualFilters
();
107
}
108
114
public
static
function
removeBlock
($blockId)
115
{
116
$res = FilterBlockTable::getList([
117
'select'
=> [
118
'ID'
119
],
120
'filter'
=> [
121
'BLOCK_ID'
=> $blockId
122
]
123
]);
124
while
($row = $res->fetch())
125
{
126
FilterBlockTable::delete($row[
'ID'
]);
127
}
128
unset($res, $row);
129
self::actualFilters
();
130
}
131
136
protected
static
function
actualFilters
(): void
137
{
138
$connection =
Application::getConnection
();
139
if
($connection->getType() ===
'pgsql'
)
140
{
141
$connection->query(
'
142
DELETE FROM b_landing_filter_entity
143
WHERE ID IN (
144
SELECT F.ID
145
FROM b_landing_filter_entity F
146
LEFT JOIN b_landing_filter_block B ON B.FILTER_ID = F.ID
147
WHERE B.ID IS NULL
148
);
149
'
);
150
}
else
{
151
$connection->query(
'
152
DELETE F FROM
153
b_landing_filter_entity F
154
LEFT JOIN
155
b_landing_filter_block B ON B.FILTER_ID = F.ID
156
WHERE
157
B.ID IS NULL;
158
'
);
159
}
160
}
161
}
Bitrix\Landing\Internals\FilterEntityTable
Definition
filterentity.php:27
Bitrix\Landing\Internals\FilterEntityTable\getMap
static getMap()
Definition
filterentity.php:41
Bitrix\Landing\Internals\FilterEntityTable\applyBlock
static applyBlock($filterId, $blockId)
Definition
filterentity.php:87
Bitrix\Landing\Internals\FilterEntityTable\removeBlock
static removeBlock($blockId)
Definition
filterentity.php:114
Bitrix\Landing\Internals\FilterEntityTable\actualFilters
static actualFilters()
Definition
filterentity.php:136
Bitrix\Landing\Internals\FilterEntityTable\getTableName
static getTableName()
Definition
filterentity.php:32
Bitrix\Main\Application
Definition
application.php:28
Bitrix\Main\Application\getConnection
static getConnection($name="")
Definition
application.php:611
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\loadMessages
static loadMessages($file)
Definition
loc.php:64
Bitrix\Main\Localization\Loc\getMessage
static getMessage($code, $replace=null, $language=null)
Definition
loc.php:29
Bitrix\Main\ORM\Entity
Definition
entity.php:26
Bitrix\Main\ORM\Fields\DatetimeField
Definition
datetimefield.php:22
Bitrix\Main\ORM\Fields\IntegerField
Definition
integerfield.php:20
Bitrix\Main\ORM\Fields\StringField
Definition
stringfield.php:20
Bitrix\Landing\Internals
Definition
base.php:2
modules
landing
lib
internals
filterentity.php
Создано системой
1.10.0