-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[DI] Added _instanceof example #8496
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
|
||
<instanceof id="AppBundle\Domain\LoaderInterface" public="true"> | ||
<tag name="app.domain_loader" /> | ||
</instanceof> |
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.
Here I fixed a closing tag
<services> | ||
<!-- ... --> | ||
|
||
<instanceof id="AppBundle\Domain\LoaderInterface" public="true"> |
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.
Here I replaced class
by id
service_container/3.3-di-changes.rst
Outdated
use AppBundle\Domain\LoaderInterface; | ||
|
||
$container->registerForAutoconfiguration(LoaderInterface::class) | ||
->addTag('app.domain_loader'); |
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.
And here I rewrote the whole thing, it looked like it was an unfinished copy/paste. I no longer use setInstanceofConditionals
, not sure what's best, please tell me.
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.
It's ok to use this shortcut but unlike other formats it's missing // ...
at the beginning to remind classes should be auto-registered first before being auto configured.
Maybe this function could be better documented with some extra comment, i.e: "This method returns a child definition to define the default configuration of the given class/interface.`.
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.
Thanks, addressed!
service_container/3.3-di-changes.rst
Outdated
And the final big change is ``_instanceof``. It acts as a default definition | ||
template (see `service-33-default_definition`_), but only for services whose | ||
class matches a defined one. | ||
This can be very useful when many services share some tag that cannot be |
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 you want to make this a new paragraph, there must be a blank line before it. Otherwise, I would not break lines here.
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.
You mean you would break them at this point of the sentence or you wouldn't break at all?
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 the sf docs standards explicitely state lines should be broken when exceeding 72 chars
471adf7
to
4eacede
Compare
Thanks for finishing this :). |
4eacede
to
691c547
Compare
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.
Thank you 👍
Thank you @greg0ire. |
|
||
/* This method returns a child definition to define the default | ||
configuration of the given class or interface */ | ||
$container->registerForAutoconfiguration(LoaderInterface::class) |
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 call is not about the _instanceof
. It is about registering custom logic for services using autoconfigure
.
The new PHP DSL has a syntax to define the _instanceof conditionals. The old syntax does not, because it uses the ContainerBuilder directly and so cannot provide file-scoped features.
@HeahDude seems to be away, and I think this is badly needed in the docs, so let's carry his PR.
Closes #8239