1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
categoryprovider.php
См. документацию.
1<?php
2
4
13
14final class CategoryProvider extends BaseProvider
15{
16 public const ENTITY_ID = 'event-category';
17
18 protected int $userId;
19
20 public function __construct()
21 {
22 parent::__construct();
23
24 $this->userId = (int)CurrentUser::get()->getId();
25 }
26
27 public function isAvailable(): bool
28 {
29 return $this->userId > 0;
30 }
31
32 public function getItems(array $ids): array
33 {
34 return $this->getCategories();
35 }
36
37 public function fillDialog(Dialog $dialog): void
38 {
39 $dialog->addItems($this->getCategories());
40 }
41
42 public function getCategories(): array
43 {
44 $categoryQuery = new Provider\Category\Query(
45 order: CategoryOrderEnum::BY_NAME,
46 requireDefault: true,
47 );
48
49 $categories = (new Provider\CategoryProvider($this->userId))->list($categoryQuery);
50
51 return $this->getItemsFromCategories($categories);
52 }
53
54 public function getItemsFromCategories(array $categories): array
55 {
56 return array_map(static fn (Category $it) => self::makeItem($it), $categories);
57 }
58
59 public function doSearch(SearchQuery $searchQuery, Dialog $dialog): void
60 {
61 $filter = new Provider\Category\Filter(
62 query: $searchQuery->getQuery(),
63 );
64
65 $categoryQuery = new Provider\Category\Query(
66 filter: $filter,
67 order: CategoryOrderEnum::BY_NAME,
68 );
69
70 $categories = (new Provider\CategoryProvider($this->userId))->list($categoryQuery);
71
72 foreach ($categories as $category)
73 {
74 $dialog->addItem(self::makeItem($category));
75 }
76 }
77
78 protected static function makeItem(Category $category): Item
79 {
80 return new Item([
81 'id' => $category->id,
82 'entityId' => self::ENTITY_ID,
83 'title' => $category->name,
84 'tabs' => 'recents',
85 ]);
86 }
87}
doSearch(SearchQuery $searchQuery, Dialog $dialog)
Определения categoryprovider.php:59
Определения dialog.php:11
addItems(array $items)
Определения dialog.php:135
addItem(Item $item)
Определения dialog.php:126
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$filter
Определения iblock_catalog_list.php:54