@@ -126,12 +126,12 @@ |
||
126 | 126 | $hosts = $this->configService->getElasticHost(); |
127 | 127 | foreach ($hosts as $host) { |
128 | 128 | $parsedHost = parse_url($host); |
129 | - $safeHost = $parsedHost['scheme'] . '://'; |
|
129 | + $safeHost = $parsedHost['scheme'].'://'; |
|
130 | 130 | if (array_key_exists('user', $parsedHost)) { |
131 | - $safeHost .= $parsedHost['user'] . ':' . '********' . '@'; |
|
131 | + $safeHost .= $parsedHost['user'].':'.'********'.'@'; |
|
132 | 132 | } |
133 | 133 | $safeHost .= $parsedHost['host']; |
134 | - $safeHost .= ':' . $parsedHost['port']; |
|
134 | + $safeHost .= ':'.$parsedHost['port']; |
|
135 | 135 | |
136 | 136 | $sanitizedHosts[] = $safeHost; |
137 | 137 | } |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | * @throws Exception |
132 | 132 | */ |
133 | 133 | public function loadPlatform() { |
134 | - $this->connectToElastic($this->configService->getElasticHost()); |
|
134 | + $this->connectToElastic($this->configService->getElasticHost()); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | |
@@ -383,29 +383,29 @@ discard block |
||
383 | 383 | * @throws Exception |
384 | 384 | */ |
385 | 385 | private function connectToElastic(array $hosts): void { |
386 | - $hosts = array_map([$this, 'cleanHost'], $hosts); |
|
387 | - $cb = ClientBuilder::create() |
|
388 | - ->setHosts($hosts) |
|
389 | - ->setRetries(3); |
|
390 | - $this->configureAuthentication($cb, $hosts); |
|
391 | - |
|
392 | - $this->client = $cb->build(); |
|
393 | - } |
|
394 | - |
|
395 | - /** |
|
396 | - * setBasicAuthentication() on ClientBuilder if available, using list of hosts |
|
397 | - */ |
|
398 | - private function configureAuthentication(ClientBuilder $cb, array $hosts): void { |
|
399 | - foreach ($hosts as $host) { |
|
400 | - $user = parse_url($host, PHP_URL_USER) ?? ''; |
|
401 | - $pass = parse_url($host, PHP_URL_PASS) ?? ''; |
|
402 | - |
|
403 | - if ($user !== '' || $pass !== '') { |
|
404 | - $cb->setBasicAuthentication($user, $pass); |
|
405 | - return; |
|
406 | - } |
|
407 | - } |
|
408 | - } |
|
386 | + $hosts = array_map([$this, 'cleanHost'], $hosts); |
|
387 | + $cb = ClientBuilder::create() |
|
388 | + ->setHosts($hosts) |
|
389 | + ->setRetries(3); |
|
390 | + $this->configureAuthentication($cb, $hosts); |
|
391 | + |
|
392 | + $this->client = $cb->build(); |
|
393 | + } |
|
394 | + |
|
395 | + /** |
|
396 | + * setBasicAuthentication() on ClientBuilder if available, using list of hosts |
|
397 | + */ |
|
398 | + private function configureAuthentication(ClientBuilder $cb, array $hosts): void { |
|
399 | + foreach ($hosts as $host) { |
|
400 | + $user = parse_url($host, PHP_URL_USER) ?? ''; |
|
401 | + $pass = parse_url($host, PHP_URL_PASS) ?? ''; |
|
402 | + |
|
403 | + if ($user !== '' || $pass !== '') { |
|
404 | + $cb->setBasicAuthentication($user, $pass); |
|
405 | + return; |
|
406 | + } |
|
407 | + } |
|
408 | + } |
|
409 | 409 | |
410 | 410 | |
411 | 411 | /** |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | foreach ($keys as $key) { |
405 | 405 | if (!array_key_exists($key, $arr)) { |
406 | 406 | throw new MalformedArrayException( |
407 | - 'source: ' . json_encode($arr) . ' - missing key: ' . $key |
|
407 | + 'source: '.json_encode($arr).' - missing key: '.$key |
|
408 | 408 | ); |
409 | 409 | } |
410 | 410 | } |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | protected function cleanArray(array &$arr) { |
418 | 418 | $arr = array_filter( |
419 | 419 | $arr, |
420 | - function ($v) { |
|
420 | + function($v) { |
|
421 | 421 | if (is_string($v)) { |
422 | 422 | return ($v !== ''); |
423 | 423 | } |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | 'index' => |
68 | 68 | [ |
69 | 69 | 'index' => $this->configService->getElasticIndex(), |
70 | - 'id' => $document->getProviderId() . ':' . $document->getId(), |
|
70 | + 'id' => $document->getProviderId().':'.$document->getId(), |
|
71 | 71 | 'body' => $this->generateIndexBody($document) |
72 | 72 | ] |
73 | 73 | ]; |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | 'index' => |
96 | 96 | [ |
97 | 97 | 'index' => $this->configService->getElasticIndex(), |
98 | - 'id' => $document->getProviderId() . ':' . $document->getId(), |
|
98 | + 'id' => $document->getProviderId().':'.$document->getId(), |
|
99 | 99 | 'body' => ['doc' => $this->generateIndexBody($document)] |
100 | 100 | ] |
101 | 101 | ]; |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | 'index' => |
126 | 126 | [ |
127 | 127 | 'index' => $this->configService->getElasticIndex(), |
128 | - 'id' => $providerId . ':' . $documentId, |
|
128 | + 'id' => $providerId.':'.$documentId, |
|
129 | 129 | ] |
130 | 130 | ]; |
131 | 131 |
@@ -34,7 +34,7 @@ |
||
34 | 34 | use OCP\AppFramework\Bootstrap\IBootstrap; |
35 | 35 | use OCP\AppFramework\Bootstrap\IRegistrationContext; |
36 | 36 | |
37 | -require_once __DIR__ . '/../../vendor/autoload.php'; |
|
37 | +require_once __DIR__.'/../../vendor/autoload.php'; |
|
38 | 38 | |
39 | 39 | class Application extends App implements IBootstrap { |
40 | 40 |
@@ -48,8 +48,7 @@ discard block |
||
48 | 48 | */ |
49 | 49 | class SearchMappingService { |
50 | 50 | |
51 | - public function __construct |
|
52 | - ( |
|
51 | + public function __construct( |
|
53 | 52 | private ConfigService $configService |
54 | 53 | ) { |
55 | 54 | } |
@@ -275,7 +274,7 @@ discard block |
||
275 | 274 | |
276 | 275 | foreach ($request->getWildcardFields() as $field) { |
277 | 276 | if (!$this->fieldIsOutLimit($request, $field)) { |
278 | - $queryFields[] = ['wildcard' => [$field => '*' . $content->getWord() . '*']]; |
|
277 | + $queryFields[] = ['wildcard' => [$field => '*'.$content->getWord().'*']]; |
|
279 | 278 | } |
280 | 279 | } |
281 | 280 | |
@@ -439,7 +438,7 @@ discard block |
||
439 | 438 | public function getDocumentQuery(string $providerId, string $documentId): array { |
440 | 439 | return [ |
441 | 440 | 'index' => $this->configService->getElasticIndex(), |
442 | - 'id' => $providerId . ':' . $documentId |
|
441 | + 'id' => $providerId.':'.$documentId |
|
443 | 442 | ]; |
444 | 443 | } |
445 | 444 | |
@@ -451,8 +450,8 @@ discard block |
||
451 | 450 | */ |
452 | 451 | private function getPartsFields(ISearchRequest $request): array { |
453 | 452 | return array_map( |
454 | - function (string $value): string { |
|
455 | - return 'parts.' . $value; |
|
453 | + function(string $value): string { |
|
454 | + return 'parts.'.$value; |
|
456 | 455 | }, $request->getParts() |
457 | 456 | ); |
458 | 457 | } |