1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
AppRepository.php
См. документацию.
1<?php
2
3namespace Bitrix\Rest\Repository;
4
5use Bitrix\Main\ORM\Query\Query;
6use Bitrix\Rest\AppTable;
7use Bitrix\Rest\Entity\Collection\AppCollection;
8use Bitrix\Rest\EO_App_Collection;
9use Bitrix\Rest\EO_App_Query;
10
12{
13 public function __construct(
14 private readonly \Bitrix\Rest\Model\Mapper\App $mapper,
15 )
16 {}
17
19 {
20 $appList = $this->buildPaidAppsQuery()
21 ->addSelect('*')
22 ->fetchCollection();
23
24 return $this->createAppCollectionFromModelArray($appList);
25 }
26
27 public function hasPaidApps(): bool
28 {
29 $collection = $this->buildPaidAppsQuery()
30 ->setSelect(['ID'])
31 ->setLimit(1)
32 ->fetch();
33
34 return !empty($collection);
35 }
36
40 private function buildPaidAppsQuery(): Query
41 {
42 return AppTable::query()
43 ->addFilter('!=STATUS', AppTable::STATUS_LOCAL)
44 ->addFilter('=ACTIVE', AppTable::ACTIVE)
45 ->addFilter('IS_FREE', false);
46 }
47
53 private function createAppCollectionFromModelArray(EO_App_Collection $modelCollection): AppCollection
54 {
55 $collection = new AppCollection();
56 foreach ($modelCollection as $model)
57 {
58 $collection->add($this->mapper->mapModelToEntity($model));
59 }
60
61 return $collection;
62 }
63}
Определения app.php:1313
const STATUS_LOCAL
Определения app.php:84
const ACTIVE
Определения app.php:69
__construct(private readonly \Bitrix\Rest\Model\Mapper\App $mapper,)
Определения AppRepository.php:13
Определения chain.php:3
Определения handlers.php:8