mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-02 15:51:48 +03:00
Merge remote-tracking branch 'Tobion/optional_form'
This commit is contained in:
commit
7336197536
36
DependencyInjection/LoadExtractorParsersPass.php
Normal file
36
DependencyInjection/LoadExtractorParsersPass.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Nelmio\ApiDocBundle\DependencyInjection;
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
|
||||
use Symfony\Component\Config\FileLocator;
|
||||
|
||||
/**
|
||||
* Loads parsers to extract information from different libraries.
|
||||
*
|
||||
* They are only loaded when the corresponding library is installed and enabled.
|
||||
*/
|
||||
class LoadExtractorParsersPass implements CompilerPassInterface
|
||||
{
|
||||
public function process(ContainerBuilder $container)
|
||||
{
|
||||
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
|
||||
|
||||
// JMS may or may not be installed, if it is, load that config as well
|
||||
if ($container->hasDefinition('jms_serializer.serializer')) {
|
||||
$loader->load('services.jms.xml');
|
||||
}
|
||||
|
||||
// forms may not be installed/enabled, if it is, load that config as well
|
||||
if ($container->hasDefinition('form.factory')) {
|
||||
$loader->load('services.form.xml');
|
||||
}
|
||||
|
||||
// validation may not be installed/enabled, if it is, load that config as well
|
||||
if ($container->hasDefinition('validator.mapping.class_metadata_factory')) {
|
||||
$loader->load('services.validation.xml');
|
||||
}
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Nelmio\ApiDocBundle\DependencyInjection;
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
|
||||
use Symfony\Component\Config\FileLocator;
|
||||
|
||||
class RegisterJmsParserPass implements CompilerPassInterface
|
||||
{
|
||||
public function process(ContainerBuilder $container)
|
||||
{
|
||||
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
|
||||
|
||||
//JMS may or may not be installed, if it is, load that config as well
|
||||
if ($container->hasDefinition('jms_serializer.serializer')) {
|
||||
$loader->load('services.jms.xml');
|
||||
}
|
||||
}
|
||||
}
|
@ -14,7 +14,6 @@ namespace Nelmio\ApiDocBundle\EventListener;
|
||||
use Nelmio\ApiDocBundle\Extractor\ApiDocExtractor;
|
||||
use Nelmio\ApiDocBundle\Formatter\FormatterInterface;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
|
||||
|
||||
|
@ -4,10 +4,9 @@ namespace Nelmio\ApiDocBundle;
|
||||
|
||||
use Symfony\Component\HttpKernel\Bundle\Bundle;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Nelmio\ApiDocBundle\DependencyInjection\RegisterJmsParserPass;
|
||||
use Nelmio\ApiDocBundle\DependencyInjection\LoadExtractorParsersPass;
|
||||
use Nelmio\ApiDocBundle\DependencyInjection\RegisterExtractorParsersPass;
|
||||
use Nelmio\ApiDocBundle\DependencyInjection\ExtractorHandlerCompilerPass;
|
||||
use Nelmio\ApiDocBundle\DependencyInjection\ParserHandlerCompilerPass;
|
||||
|
||||
class NelmioApiDocBundle extends Bundle
|
||||
{
|
||||
@ -15,7 +14,7 @@ class NelmioApiDocBundle extends Bundle
|
||||
{
|
||||
parent::build($container);
|
||||
|
||||
$container->addCompilerPass(new RegisterJmsParserPass());
|
||||
$container->addCompilerPass(new LoadExtractorParsersPass());
|
||||
$container->addCompilerPass(new RegisterExtractorParsersPass());
|
||||
$container->addCompilerPass(new ExtractorHandlerCompilerPass());
|
||||
}
|
||||
|
@ -4,8 +4,6 @@
|
||||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
|
||||
|
||||
<parameters>
|
||||
<parameter key="nelmio_api_doc.parser.form_type_parser.class">Nelmio\ApiDocBundle\Parser\FormTypeParser</parameter>
|
||||
<parameter key="nelmio_api_doc.parser.validation_parser.class">Nelmio\ApiDocBundle\Parser\ValidationParser</parameter>
|
||||
<parameter key="nelmio_api_doc.formatter.abstract_formatter.class">Nelmio\ApiDocBundle\Formatter\AbstractFormatter</parameter>
|
||||
<parameter key="nelmio_api_doc.formatter.markdown_formatter.class">Nelmio\ApiDocBundle\Formatter\MarkdownFormatter</parameter>
|
||||
<parameter key="nelmio_api_doc.formatter.simple_formatter.class">Nelmio\ApiDocBundle\Formatter\SimpleFormatter</parameter>
|
||||
@ -14,14 +12,6 @@
|
||||
</parameters>
|
||||
|
||||
<services>
|
||||
<service id="nelmio_api_doc.parser.form_type_parser" class="%nelmio_api_doc.parser.form_type_parser.class%">
|
||||
<argument type="service" id="form.factory" />
|
||||
<tag name="nelmio_api_doc.extractor.parser" />
|
||||
</service>
|
||||
<service id="nelmio_api_doc.parser.validation_parser" class="%nelmio_api_doc.parser.validation_parser.class%">
|
||||
<argument type="service" id="validator.mapping.class_metadata_factory"/>
|
||||
<tag name="nelmio_api_doc.extractor.parser" />
|
||||
</service>
|
||||
<service id="nelmio_api_doc.formatter.abstract_formatter" class="%nelmio_api_doc.formatter.abstract_formatter.class%" />
|
||||
<service id="nelmio_api_doc.formatter.markdown_formatter" class="%nelmio_api_doc.formatter.markdown_formatter.class%"
|
||||
parent="nelmio_api_doc.formatter.abstract_formatter" />
|
||||
|
17
Resources/config/services.form.xml
Normal file
17
Resources/config/services.form.xml
Normal file
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" ?>
|
||||
<container xmlns="http://symfony.com/schema/dic/services"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
|
||||
|
||||
<parameters>
|
||||
<parameter key="nelmio_api_doc.parser.form_type_parser.class">Nelmio\ApiDocBundle\Parser\FormTypeParser</parameter>
|
||||
</parameters>
|
||||
|
||||
<services>
|
||||
<service id="nelmio_api_doc.parser.form_type_parser" class="%nelmio_api_doc.parser.form_type_parser.class%">
|
||||
<argument type="service" id="form.factory" />
|
||||
<tag name="nelmio_api_doc.extractor.parser" />
|
||||
</service>
|
||||
</services>
|
||||
|
||||
</container>
|
17
Resources/config/services.validation.xml
Normal file
17
Resources/config/services.validation.xml
Normal file
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" ?>
|
||||
<container xmlns="http://symfony.com/schema/dic/services"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
|
||||
|
||||
<parameters>
|
||||
<parameter key="nelmio_api_doc.parser.validation_parser.class">Nelmio\ApiDocBundle\Parser\ValidationParser</parameter>
|
||||
</parameters>
|
||||
|
||||
<services>
|
||||
<service id="nelmio_api_doc.parser.validation_parser" class="%nelmio_api_doc.parser.validation_parser.class%">
|
||||
<argument type="service" id="validator.mapping.class_metadata_factory" />
|
||||
<tag name="nelmio_api_doc.extractor.parser" />
|
||||
</service>
|
||||
</services>
|
||||
|
||||
</container>
|
@ -17,7 +17,7 @@
|
||||
"require": {
|
||||
"symfony/framework-bundle": "~2.1",
|
||||
"symfony/twig-bundle": "~2.1",
|
||||
"symfony/form": "~2.1",
|
||||
"symfony/console": "~2.1",
|
||||
"dflydev/markdown": "1.0.*"
|
||||
},
|
||||
"conflict": {
|
||||
@ -29,10 +29,17 @@
|
||||
"symfony/browser-kit": "~2.1",
|
||||
"symfony/validator": "~2.1",
|
||||
"symfony/yaml": "~2.1",
|
||||
"symfony/form": "~2.1",
|
||||
"friendsofsymfony/rest-bundle": "0.12.*@dev",
|
||||
"jms/serializer-bundle": ">=0.11",
|
||||
"sensio/framework-extra-bundle": "~2.1"
|
||||
},
|
||||
"suggest": {
|
||||
"symfony/form": "For using form definitions as input.",
|
||||
"symfony/validator": "For making use of validator information in the doc.",
|
||||
"friendsofsymfony/rest-bundle": "For making use of REST information in the doc.",
|
||||
"jms/serializer": "For making use of serializer information in the doc."
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"autoload": {
|
||||
"psr-0": { "Nelmio\\ApiDocBundle": "" }
|
||||
|
Loading…
x
Reference in New Issue
Block a user