Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
RecentSearchManager.php
1
<?php
2
namespace
Bitrix\Socialnetwork\Space\List\RecentSearch
;
3
4
use
Bitrix\Main\ObjectException
;
5
use
Bitrix\Main\Type\DateTime
;
6
use
Bitrix\Main\UI\EntitySelector\EntityUsageTable
;
7
8
final
class
RecentSearchManager
9
{
10
private
const
CONTEXT =
'SOCIALNETWORK_SPACE_LIST'
;
11
private
const
ENTITY_ID =
'socnet-space'
;
12
private
const
LOAD_LIMIT = 40;
13
14
public
function
__construct
(
private
int
$userId)
15
{}
16
17
public
function
addSpaceToRecentSearch
(
int
$spaceId): void
18
{
19
EntityUsageTable::merge
([
20
'USER_ID'
=> $this->userId,
21
'CONTEXT'
=> self::CONTEXT,
22
'ENTITY_ID'
=> self::ENTITY_ID,
23
'ITEM_ID'
=> $spaceId,
24
]);
25
}
26
27
public
function
getRecentlySearchedSpacesData
():
SpaceSearchDataCollection
28
{
29
$result =
new
SpaceSearchDataCollection
();
30
31
$queryResult =
EntityUsageTable::query
()
32
->setSelect([
'ITEM_ID'
,
'LAST_USE_DATE'
])
33
->where(
'USER_ID'
, $this->userId)
34
->where(
'CONTEXT'
, self::CONTEXT)
35
->where(
'ENTITY_ID'
, self::ENTITY_ID)
36
->addOrder(
'LAST_USE_DATE'
,
'DESC'
)
37
->setLimit(self::LOAD_LIMIT)
38
->setDistinct()
39
->fetchAll()
40
;
41
42
foreach
($queryResult as $value)
43
{
44
try
45
{
46
$result->add(
new
SpaceSearchData
((
int
)$value[
'ITEM_ID'
],
new
DateTime
($value[
'LAST_USE_DATE'
])));
47
}
48
catch
(
ObjectException
$exception) {}
49
}
50
51
return
$result;
52
}
53
}
Bitrix\Main\ORM\Data\DataManager\query
static query()
Definition
datamanager.php:559
Bitrix\Main\ObjectException
Definition
exception.php:192
Bitrix\Main\Type\DateTime
Definition
datetime.php:9
Bitrix\Main\UI\EntitySelector\EntityUsageTable
Definition
entityusagetable.php:31
Bitrix\Main\UI\EntitySelector\EntityUsageTable\merge
static merge(array $data)
Definition
entityusagetable.php:144
Bitrix\Socialnetwork\Space\List\RecentSearch\RecentSearchManager
Definition
RecentSearchManager.php:9
Bitrix\Socialnetwork\Space\List\RecentSearch\RecentSearchManager\addSpaceToRecentSearch
addSpaceToRecentSearch(int $spaceId)
Definition
RecentSearchManager.php:17
Bitrix\Socialnetwork\Space\List\RecentSearch\RecentSearchManager\getRecentlySearchedSpacesData
getRecentlySearchedSpacesData()
Definition
RecentSearchManager.php:27
Bitrix\Socialnetwork\Space\List\RecentSearch\RecentSearchManager\__construct
__construct(private int $userId)
Definition
RecentSearchManager.php:14
Bitrix\Socialnetwork\Space\List\RecentSearch\SpaceSearchDataCollection
Definition
SpaceSearchDataCollection.php:8
Bitrix\Socialnetwork\Space\List\RecentSearch\SpaceSearchData
Definition
SpaceSearchData.php:8
Bitrix\Socialnetwork\Space\List\RecentSearch
Definition
RecentSearchManager.php:2
modules
socialnetwork
lib
Space
List
RecentSearch
RecentSearchManager.php
Создано системой
1.10.0