| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  |  * class ElasticSynonymExtension|Firesphere\ElasticSearch\Extensions\ElasticSynonymExtension Synonym updates for Elastic | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * pushed to Elastic | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * @package Firesphere\Elastic\Search | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * @author Simon `Firesphere` Erkelens; Marco `Sheepy` Hermo | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * @copyright Copyright (c) 2018 - now() Firesphere & Sheepy | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | namespace Firesphere\ElasticSearch\Extensions; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | use Elastic\Elasticsearch\Exception\ClientResponseException; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | use Elastic\Elasticsearch\Exception\MissingParameterException; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | use Elastic\Elasticsearch\Exception\ServerResponseException; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | use Firesphere\ElasticSearch\Models\SynonymSet; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | use Firesphere\ElasticSearch\Services\ElasticCoreService; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | use Firesphere\SearchBackend\Models\SearchSynonym; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | use Psr\Container\NotFoundExceptionInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | use SilverStripe\Core\Injector\Injector; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | use SilverStripe\Forms\FieldList; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  | use SilverStripe\ORM\DataExtension; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |  * Class \Firesphere\ElasticSearch\Extensions\ElasticSynonymExtension | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |  * @property SearchSynonym|ElasticSynonymExtension $owner | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  | class ElasticSynonymExtension extends DataExtension | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |      * Add or update this synonym in Elastic | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |      * @throws NotFoundExceptionInterface | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |     public function onAfterWrite() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |         $service = Injector::inst()->get(ElasticCoreService::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |         /** @var SearchSynonym|ElasticSynonymExtension $owner */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |         $owner = $this->owner; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |         $syn = $service->getClient()->synonyms(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |         /** @var SynonymSet $set */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |         $set = SynonymSet::get()->first(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |         $syn->putSynonymRule([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |             'set_id'  => $set->Key, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |             'rule_id' => $owner->getModifiedID(), | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |             'body'    => [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |                 'synonyms' => $owner->getCombinedSynonym() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |             ] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |         ]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |      * When deleting a synonym from the CMS, delete it as a rule | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |      * @throws NotFoundExceptionInterface | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 57 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 58 |  |  |     public function onAfterDelete() | 
            
                                                                        
                            
            
                                    
            
            
                | 59 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 60 |  |  |         $service = Injector::inst()->get(ElasticCoreService::class); | 
            
                                                                        
                            
            
                                    
            
            
                | 61 |  |  |         $syn = $service->getClient()->synonyms(); | 
            
                                                                        
                            
            
                                    
            
            
                | 62 |  |  |         /** @var SearchSynonym $owner */ | 
            
                                                                        
                            
            
                                    
            
            
                | 63 |  |  |         $owner = $this->owner; | 
            
                                                                        
                            
            
                                    
            
            
                | 64 |  |  |         /** @var SynonymSet $set */ | 
            
                                                                        
                            
            
                                    
            
            
                | 65 |  |  |         $set = SynonymSet::get()->first(); | 
            
                                                                        
                            
            
                                    
            
            
                | 66 |  |  |         $syn->deleteSynonymRule(['set_id' => $set->Key, 'rule_id' => $owner->getModifiedId()]); | 
            
                                                                        
                            
            
                                    
            
            
                | 67 |  |  |         parent::onAfterDelete(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 69 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 70 |  |  |  | 
            
                        
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.