1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
IntegrationRepository.php
См. документацию.
1<?php
2
3namespace Bitrix\Rest\Repository;
4
5use Bitrix\Main\Entity\Query;
6use Bitrix\Rest\Entity\Collection\IntegrationCollection;
7use Bitrix\Rest\Entity\Integration;
8use Bitrix\Rest\Enum\APAuth\PasswordType;
9use Bitrix\Rest\Enum\Integration\ElementCodeType;
10use Bitrix\Rest\Preset\EO_Integration_Query;
11use Bitrix\Rest\Preset\IntegrationTable;
12
14{
15 public function __construct(
16 private readonly \Bitrix\Rest\Model\Mapper\Integration $mapper,
17 )
18 {}
19
21 {
22 $integrationList = $this->buildNotSystemIntegrationsQuery()
23 ->addSelect('*')
24 ->setOrder(['ID' => 'ASC'])
25 ->fetchAll();
26
27 return $this->createIntegrationCollectionFromModelArray($integrationList);
28 }
29
31 {
32 $integrationList = $this->buildNotSystemIntegrationsQuery()
33 ->addSelect('*')
34 ->setOrder(['ID' => 'ASC'])
35 ->addFilter('!=ELEMENT_CODE', ElementCodeType::IN_WEBHOOK->value)
36 ->fetchAll();
37
38 return $this->createIntegrationCollectionFromModelArray($integrationList);
39 }
40
41 public function hasUserIntegrations(): bool
42 {
43 $integration = $this->buildNotSystemIntegrationsQuery()
44 ->setLimit(1)
45 ->setSelect(['ID']);
46
47 return !empty($integration->fetch());
48 }
49
50 public function hasNotInWebhookUserIntegrations(): bool
51 {
52 $query = $this->buildNotSystemIntegrationsQuery()
53 ->setLimit(1)
54 ->setSelect(['ID'])
55 ->addFilter('!=ELEMENT_CODE', ElementCodeType::IN_WEBHOOK->value);
56
57 return !empty($query->fetch());
58 }
59
63 private function buildNotSystemIntegrationsQuery(): Query
64 {
65 return IntegrationTable::query()
66 ->where(Query::filter()
67 ->logic('or')
68 ->where([
69 ['PASSWORD.TYPE', PasswordType::User->value],
70 ['PASSWORD.TYPE', null]
71 ])
72 );
73 }
74
75 public function getById(int $id): ?Integration
76 {
77 $integration = IntegrationTable::query()
78 ->addSelect('*')
79 ->where('ID', $id)
80 ->setLimit(1)
81 ->fetch();
82
83 if (!$integration)
84 {
85 return null;
86 }
87
88 return $this->mapper->mapArrayToEntity($integration);
89 }
90
96 private function createIntegrationCollectionFromModelArray(array $modelCollection): IntegrationCollection
97 {
98 $collection = new IntegrationCollection();
99 foreach ($modelCollection as $model)
100 {
101 $collection->add($this->mapper->mapArrayToEntity($model));
102 }
103
104 return $collection;
105 }
106}
__construct(private readonly \Bitrix\Rest\Model\Mapper\Integration $mapper,)
Определения IntegrationRepository.php:15
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$query
Определения get_search.php:11
Определения chain.php:3
Определения handlers.php:8