Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass name to custom driver #2781

Merged
merged 1 commit into from
Nov 5, 2020

Conversation

tomhelmer
Copy link
Contributor

@tomhelmer tomhelmer commented Nov 1, 2020

When creating a custom driver the name from the config is not passed.

In my case I'm extending with a custom search driver, but the index name public is currently not available in the custom creator callback. So the custom driver don't know how to name the index.

This PR passes the config name as a third parameter to the custom creator callback.

Example config:

'indexes' => [
    'public' => [
         'driver' => '<my-custom-driver>',
         'searchables' => 'collection:<my-collection-name>',
         'fields' => ['title', 'description'],
    ],
],

@jasonvarga
Copy link
Member

I was hesitant to merge because it would make the order of arguments different from a similar situation in Laravel.

This is what it would look like now for us when registering a custom search index:

Search::extend('elasticsearch', function ($app, $config, $name) {

In Laravel:

image

But when keys aren't necessary, the $config comes first:

image

And sometimes it's completely different anyway:
image

So 🤷 we'll go with what you've done. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants