2017-12-19 20:35:10 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This file is part of the NelmioApiDocBundle package.
|
|
|
|
*
|
|
|
|
* (c) Nelmio
|
|
|
|
*
|
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Nelmio\ApiDocBundle\DependencyInjection\Compiler;
|
|
|
|
|
|
|
|
use Nelmio\ApiDocBundle\ModelDescriber\FormModelDescriber;
|
|
|
|
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
|
|
|
use Symfony\Component\DependencyInjection\Reference;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Enables the FormModelDescriber only if forms are enabled.
|
|
|
|
*
|
|
|
|
* @internal
|
|
|
|
*/
|
|
|
|
final class ConfigurationPass implements CompilerPassInterface
|
|
|
|
{
|
|
|
|
public function process(ContainerBuilder $container)
|
|
|
|
{
|
|
|
|
if ($container->hasDefinition('form.factory')) {
|
|
|
|
$container->register('nelmio_api_doc.model_describers.form', FormModelDescriber::class)
|
|
|
|
->setPublic(false)
|
|
|
|
->addArgument(new Reference('form.factory'))
|
2020-12-29 10:27:09 +01:00
|
|
|
->addArgument(new Reference('annotations.reader'))
|
2020-12-10 22:28:55 +01:00
|
|
|
->addArgument($container->getParameter('nelmio_api_doc.media_types'))
|
2017-12-19 20:35:10 +01:00
|
|
|
->addTag('nelmio_api_doc.model_describer', ['priority' => 100]);
|
|
|
|
}
|
2020-12-10 22:28:55 +01:00
|
|
|
|
|
|
|
$container->getParameterBag()->remove('nelmio_api_doc.media_types');
|
2017-12-19 20:35:10 +01:00
|
|
|
}
|
|
|
|
}
|