1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* This file is part of Scout Extended. |
7
|
|
|
* |
8
|
|
|
* (c) Algolia Team <[email protected]> |
9
|
|
|
* |
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
11
|
|
|
* file that was distributed with this source code. |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace Algolia\ScoutExtended\Repositories; |
15
|
|
|
|
16
|
|
|
use Algolia\AlgoliaSearch\Index; |
|
|
|
|
17
|
|
|
use Algolia\ScoutExtended\Settings\Settings; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @internal |
21
|
|
|
*/ |
22
|
|
|
final class UserDataRepository |
23
|
|
|
{ |
24
|
|
|
/** |
25
|
|
|
* @var \Algolia\ScoutExtended\Repositories\RemoteSettingsRepository |
26
|
|
|
*/ |
27
|
|
|
private $remoteRepository; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* UserDataRepository constructor. |
31
|
|
|
* |
32
|
|
|
* @param \Algolia\ScoutExtended\Repositories\RemoteSettingsRepository $remoteRepository |
33
|
|
|
*/ |
34
|
|
|
public function __construct(RemoteSettingsRepository $remoteRepository) |
35
|
|
|
{ |
36
|
|
|
$this->remoteRepository = $remoteRepository; |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Find the User Data of the given Index. |
41
|
|
|
* |
42
|
|
|
* @param \Algolia\AlgoliaSearch\Index $index |
43
|
|
|
* |
44
|
|
|
* @return array |
45
|
|
|
*/ |
46
|
|
|
public function find(Index $index): array |
47
|
|
|
{ |
48
|
|
|
$settings = $this->remoteRepository->getSettingsRaw($index); |
49
|
|
|
|
50
|
|
|
if (array_key_exists('userData', $settings)) { |
51
|
|
|
$userData = @json_decode($settings['userData']); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
return $userData ?? []; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Save the User Data of the given Index. |
59
|
|
|
* |
60
|
|
|
* @param \Algolia\AlgoliaSearch\Index $index |
61
|
|
|
* @param array $userData |
62
|
|
|
* |
63
|
|
|
* @return void |
64
|
|
|
*/ |
65
|
|
|
public function save(Index $index, array $userData): void |
66
|
|
|
{ |
67
|
|
|
$currentUserData = $this->find($index); |
68
|
|
|
|
69
|
|
|
$userDataJson = json_encode(array_merge($currentUserData, $userData)); |
70
|
|
|
|
71
|
|
|
$index->setSettings(['userData' => $userDataJson])->wait(); |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths