-
Notifications
You must be signed in to change notification settings - Fork 825
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
Documented injector configuration shorthand doesn't work, but it should #11595
Comments
Can you please provide more information? What about this doesn't work? What happens, vs what is the expected behaviour in-so-far as your understanding of the documentation? |
Sorry I found the issue: I had this configuration: SilverStripe\Core\Injector\Injector:
MyNamespace\HTTPGateway:
constructor:
0: '%$Psr\Log\LoggerInterface'
MyNamespace\Gateway: '%$MyNamespace\NullGateway' This throws the error The issue is that I have not defined the none paramethized class This works: SilverStripe\Core\Injector\Injector:
MyNamespace\HTTPGateway:
constructor:
0: '%$Psr\Log\LoggerInterface'
MyNamespace\NullGateway:
class: MyNamespace\NullGateway
MyNamespace\Gateway: '%$MyNamespace\NullGateway' And now even my later replacement with the other class works WITH copying all configurations: ---
Name: custom_my_module
After:
- 'my_module'
---
SilverStripe\Core\Injector\Injector:
MyNamespace\Gateway: '%$MyNamespace\HTTPGateway' So the only issue is that you have to explizitly define a service for a class if you wan't to use the this syntax. For example inside a Maybe one additional sentence in the documentation would help for this special case. Regardless of this, the second example misses the namespace in the reference and cannot not work. |
If it works without an explicit definition in the dependencies configuration (when an actual class with that name exists), it should probably also work without an explicitly definition in the injector configuration. This sounds like a bug in framework. |
Pages affected
https://docs.silverstripe.org/en/5/developer_guides/extending/injector/#service-inheritance
Description
I am not sure if this is a issue of the documentation or a bug:
The documentation says that you can use
App\GZIPJSONProvider: '%$App\JSONServiceDefinition'
to define an alias for another class definition. This does not work.If I read the code of the injector class correctly, using a string is just an shortcut for the class property. So omitting the '%$' prefix works but does not copy the definition.
And the second example does not contain the namespace...
Validations
The text was updated successfully, but these errors were encountered: