-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDeleteSynonymRuleAdaptor.php
More file actions
35 lines (25 loc) · 1.08 KB
/
DeleteSynonymRuleAdaptor.php
File metadata and controls
35 lines (25 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
namespace SilverStripe\ForagerBifrost\Adaptors\Requests;
use Elastic\EnterpriseSearch\AppSearch\Request\DeleteSynonymSet;
use Elastic\EnterpriseSearch\Client;
use SilverStripe\Core\Injector\Injector;
use SilverStripe\Forager\Interfaces\Requests\DeleteSynonymRuleAdaptor as DeleteSynonymRuleAdaptorInterface;
class DeleteSynonymRuleAdaptor implements DeleteSynonymRuleAdaptorInterface
{
private ?Client $client = null;
private static array $dependencies = [
'client' => '%$' . Client::class . '.managementClient',
];
public function setClient(?Client $client): void
{
$this->client = $client;
}
public function process(int|string $synonymCollectionId, int|string $synonymRuleId): bool
{
$request = Injector::inst()->create(DeleteSynonymSet::class, $synonymCollectionId, $synonymRuleId);
// Should either be successful or throw an exception, which we'll let fly
$body = $this->client->appSearch()->deleteSynonymSet($request)->asString();
$body = json_decode($body, true);
return $body['success'];
}
}