Proxy __call for access to search client methods
I needed access to the client for one-off algolia operations, but rias\scout\engines\AlgoliaEngine::algolia was protected, so I couldn't.
This adds a getter, and should be non-breaking.
For a breaking change, it might make sense to move getClient to the base class, make the prop private, maybe rename to $client?
Conceptually at least, is the idea here that there might be a non-algolia engine (eg elasticsearch)?
Just noticed that laravel\scout uses a __call so you can just call any methods on the algolia client directly: https://github.com/laravel/scout/blob/7.0/src/Engines/AlgoliaEngine.php#L232-L242
Oooh I like the __call to proxy to the Algolia client, you can implement that instead if you want
…It also might make sense to have a getIndex method, since we do this in several places:
$index = $this->algolia->initIndex($this->scoutIndex->indexName);
Codecov Report
Merging #122 into master will not change coverage. The diff coverage is
100%.
@@ Coverage Diff @@
## master #122 +/- ##
=======================================
Coverage 100% 100%
- Complexity 127 128 +1
=======================================
Files 17 17
Lines 429 431 +2
=======================================
+ Hits 429 431 +2
| Impacted Files | Coverage Δ | Complexity Δ | |
|---|---|---|---|
| src/engines/AlgoliaEngine.php | 100% <100%> (ø) |
16 <1> (+1) |
:arrow_up: |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing dataPowered by Codecov. Last update e61adeb...7c8d187. Read the comment docs.
Ok, @riasvdv I changed it to use the __call proxy instead.
Hmmm…so upon further reflection, this might need some more thought…
While I can get the client now, it is not yet configured, which kind of defeats the purpose of getting it through the scout engine…
I'll open an issue for discussion on the best approach.