-
Notifications
You must be signed in to change notification settings - Fork 55
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
3.x - Add locator #290
3.x - Add locator #290
Conversation
This resolves a deprecation error in 4.4 Fixes #288
src/Datasource/IndexLocator.php
Outdated
$options += ['name' => Inflector::underscore($classAlias)]; | ||
|
||
if (empty($options['className'])) { | ||
$options['className'] = Inflector::camelize($alias); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not add this to the += line above?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea! this is mostly copy/paste from the ORM locator.
[, $name] = pluginSplit($options['className']); | ||
$options['name'] = Inflector::underscore($name); | ||
} | ||
$options['className'] = $this->fallbackClassName; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if className
is being overwritten here, why do we use it in the if statement above?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because we only want to generate a fallback class if the inflected one does not exist. On line 86 we attempt to resolve the inflected/provided classname. If that class doesn't exist we end up here so we can use the fallbackClassName.
One potential design flaw is that allowFallbackClass
isn't used at all in this logic. Should I add that behavior or remove the ability to disable fallbackClasses? I guess we could provide a fallback class that throws an error on construction if we wanted to provide a 'strict mode'.
I could be misunderstanding the question though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea I was referring to the lack of the fallback in that logic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll get that fixed up.
} | ||
|
||
if (empty($options['connection'])) { | ||
$connectionName = $options['className']::defaultConnectionName(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is using a class name to call a static function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. This is also how the OrmLocator works as well.
Co-authored-by: othercorey <corey.taylor.fl@gmail.com>
Implement the
LocatorInterface
for this plugin. This has lead toIndexRegisty
being deprecated as we can use the locator internally instead.I've backported the docker-compose environment because I needed it for these changes too.
Fixes #288