1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
find.php
См. документацию.
1<?php
2
3namespace Bitrix\Location\Repository\Location\Strategy;
4
5use Bitrix\Location\Entity\Location;
6use Bitrix\Location\Entity\Generic\Collection;
7use Bitrix\Location\Entity\Location\Parents;
8use Bitrix\Location\Repository\Location\Capability\IFindByCoords;
9use Bitrix\Location\Repository\Location\Capability\IFindByExternalId;
10use Bitrix\Location\Repository\Location\Capability\IFindById;
11use Bitrix\Location\Repository\Location\Capability\IFindByText;
12use Bitrix\Location\Repository\Location\Capability\IFindParents;
13use Bitrix\Location\Repository\Location\Capability\ISupportAutocomplete;
14use Bitrix\Location\Repository\Location\IScope;
15use Bitrix\Location\Repository\Location\IRepository;
16use Bitrix\Location\Repository\Location\ICache;
17use Bitrix\Location\Repository\Location\IDatabase;
18
23class Find extends Base
24{
25 public function findById(int $id, string $languageId, int $searchScope)
26 {
27 return $this->find(IFindById::class, 'findById', [$id, $languageId], $searchScope);
28 }
29
30 public function findByExternalId(string $externalId, string $sourceCode, string $languageId, int $searchScope)
31 {
32 return $this->find(
33 IFindByExternalId::class,
34 'findByExternalId',
35 [
36 $externalId,
37 $sourceCode,
38 $languageId,
39 ],
40 $searchScope
41 );
42 }
43
44 public function findByCoords(
45 float $lat,
46 float $lng,
47 int $zoom,
48 string $languageId,
49 int $searchScope
50 )
51 {
52 return $this->find(
53 IFindByCoords::class,
54 'findByCoords',
55 [
56 $lat,
57 $lng,
58 $zoom,
59 $languageId,
60 ],
61 $searchScope
62 );
63 }
64
65 public function findByText(string $text, string $languageId, int $searchScope)
66 {
67 $result = $this->find(
68 IFindByText::class,
69 'findByText',
70 [
71 $text,
72 $languageId,
73 ],
74 $searchScope
75 );
76
77 return $result ?? new Location\Collection();
78 }
79
80 public function autocomplete(array $params, int $searchScope)
81 {
82 $result = $this->find(
83 ISupportAutocomplete::class,
84 'autocomplete',
85 [
86 $params,
87 ],
88 $searchScope
89 );
90
91 return $result ?? [];
92 }
93
94 public function findParents(Location $location, string $languageId, int $searchScope)
95 {
96 $result = $this->find(
97 IFindParents::class,
98 'findParents',
99 [
100 $location,
101 $languageId,
102 ],
103 $searchScope
104 );
105
106 return $result ?? new Parents();
107 }
108
111 {
112 $idx = 0;
113
114 foreach ($locationRepositories as $repository)
115 {
116 if (
117 $repository instanceof IFindById
118 || $repository instanceof IFindByExternalId
119 || $repository instanceof IFindByText
120 || $repository instanceof IFindParents
121 )
122 {
123 $key = (string)$this->getRepoPriority($repository) . (string)($idx++);
124 $this->locationRepositories[$key] = $repository;
125 }
126 }
127
128 ksort($this->locationRepositories);
129
130 return $this;
131 }
132
140 protected function find(string $interface, string $method, array $params, int $searchScope)
141 {
142 foreach ($this->locationRepositories as $repository)
143 {
144 if ($repository instanceof IScope)
145 {
146 if (!$repository->isScopeSatisfy($searchScope))
147 {
148 continue;
149 }
150 }
151
152 if ($repository instanceof $interface)
153 {
154 $result = call_user_func_array([$repository, $method], $params);
155
156 if ($result)
157 {
158 if (!($result instanceof Location\Collection) || $result->count() > 0)
159 {
160 return $result;
161 }
162 }
163 }
164 }
165
166 return null;
167 }
168
169 protected function getRepoPriority(IRepository $repository): string
170 {
171 if ($repository instanceof ICache)
172 {
173 return self::REPO_PRIORITY_A;
174 }
175 elseif ($repository instanceof IDatabase)
176 {
177 return self::REPO_PRIORITY_B;
178 }
179
180 return self::REPO_PRIORITY_C;
181 }
182}
getRepoPriority(IRepository $repository)
Определения find.php:169
find(string $interface, string $method, array $params, int $searchScope)
Определения find.php:140
findById(int $id, string $languageId, int $searchScope)
Определения find.php:25
findByExternalId(string $externalId, string $sourceCode, string $languageId, int $searchScope)
Определения find.php:30
findByCoords(float $lat, float $lng, int $zoom, string $languageId, int $searchScope)
Определения find.php:44
setLocationRepositories(array $locationRepositories)
Определения find.php:110
autocomplete(array $params, int $searchScope)
Определения find.php:80
findByText(string $text, string $languageId, int $searchScope)
Определения find.php:65
findParents(Location $location, string $languageId, int $searchScope)
Определения find.php:94
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$result
Определения get_property_values.php:14
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
if(empty($signedUserToken)) $key
Определения quickway.php:257
$text
Определения template_pdf.php:79
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения template.php:799
$location
Определения options.php:2729
$method
Определения index.php:27