-
Notifications
You must be signed in to change notification settings - Fork 3
Remove parameter name usage for AutowireDatabase #13
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
Conversation
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.
Please adjust the README examples
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 don't get the issue.
@@ -48,7 +48,7 @@ static function (Database $mydb): void { | |||
|
|||
$this->assertSame(Database::class, $definition->getClass()); | |||
$this->assertEquals($autowire->value, $definition->getFactory()); | |||
$this->assertSame('mydb', $definition->getArgument(0)); | |||
$this->assertSame('%MongoDB\Client.default_database%', $definition->getArgument(0)); |
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.
That's an ugly parameter name. Can we find something more conventional?
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.
That's an ugly parameter name. Can we find something more conventional?
I'll address that in a separate PR - maybe we can always use <clientId>.default_database
1a6f95f
to
2a2550c
Compare
Before this PR, there was no way to inject a |
As it is, there is no way to autowire the default database without explicitly specifying the name, instead it will always use the parameter name. To work around this, we remove usage of the parameter name and fall back to the default database; not specifying a
default_database
option or thedatabase
parameter in theAutowireDatabase
attribute will result in an exception. We could use some magic to fall back to the parameter name if no default database was set, but I don't believe that results an improvement and only makes for more confusing rules.