Skip to content
This repository has been archived by the owner on Feb 24, 2023. It is now read-only.

Commit

Permalink
Add autoconfigure tag for ParamConverterInterface
Browse files Browse the repository at this point in the history
  • Loading branch information
B-Galati committed Oct 13, 2017
1 parent 74f1f17 commit ba28726
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions DependencyInjection/SensioFrameworkExtraExtension.php
Expand Up @@ -11,6 +11,7 @@

namespace Sensio\Bundle\FrameworkExtraBundle\DependencyInjection;

use Sensio\Bundle\FrameworkExtraBundle\Request\ParamConverter\ParamConverterInterface;
use Symfony\Component\DependencyInjection\Alias;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
Expand Down Expand Up @@ -47,6 +48,9 @@ public function load(array $configs, ContainerBuilder $container)
if ($config['request']['converters']) {
$annotationsToLoad[] = 'converters.xml';

$container->registerForAutoconfiguration(ParamConverterInterface::class)
->addTag('request.param_converter');

$container->setParameter('sensio_framework_extra.disabled_converters', is_string($config['request']['disable']) ? implode(',', $config['request']['disable']) : $config['request']['disable']);

$container->addResource(new ClassExistenceResource(ExpressionLanguage::class));
Expand Down
6 changes: 5 additions & 1 deletion Resources/doc/annotations/converters.rst
Expand Up @@ -296,7 +296,11 @@ on the request attributes, it should set an attribute named
``$configuration->getName()``, which stores an object of class
``$configuration->getClass()``.

To register your converter service, you must add a tag to your service:
If you're using service `auto-registration and autoconfiguration`_,
you're done! Your converter will automatically be used.
If not, you must add a tag to your service:

.. _auto-registration and autoconfiguration: http://symfony.com/doc/current/service_container/3.3-di-changes.html

.. configuration-block::

Expand Down

0 comments on commit ba28726

Please sign in to comment.