Skip to content

[Container][Tags] Added a note about _instanceof #9221

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

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions service_container/tags.rst
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ that it implements ``Twig_ExtensionInterface``) and adds the tag for you.
interface, call the :method:`Symfony\\Component\\DependencyInjection\\ContainerBuilder::registerForAutoconfiguration`
method in an :doc:`extension </bundles/extension>` or from your kernel::

.. code-block:: php

// app/AppKernel.php
class AppKernel extends Kernel
{
Expand All @@ -82,6 +84,16 @@ that it implements ``Twig_ExtensionInterface``) and adds the tag for you.
}
}

If you do not want to create a custom kernel, it is also possible to use `_instanceof`:

.. code-block:: yaml
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing the xml and php documentation format. However, I'm unsure of their notations at this point.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that for PHP, setInstanceofConditionals should be called for every single definition, since there is no "file" scope context there


// app/config/services.yml
services:
_instanceof:
AppBundle\Component\CustomInterface:
tags: ['app.custom_tag']

Creating custom Tags
--------------------

Expand Down