2012-04-11 20:00:21 +02:00
|
|
|
<?php
|
|
|
|
|
2012-04-13 11:03:05 +02:00
|
|
|
/*
|
|
|
|
* This file is part of the NelmioApiDocBundle.
|
|
|
|
*
|
|
|
|
* (c) Nelmio <hello@nelm.io>
|
|
|
|
*
|
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
*/
|
|
|
|
|
2012-04-12 18:37:42 +02:00
|
|
|
namespace Nelmio\ApiDocBundle\DependencyInjection;
|
2012-04-11 20:00:21 +02:00
|
|
|
|
|
|
|
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
|
|
|
|
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
|
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
2012-04-12 20:34:19 +02:00
|
|
|
use Symfony\Component\Config\Definition\Processor;
|
2012-04-11 20:00:21 +02:00
|
|
|
use Symfony\Component\Config\FileLocator;
|
|
|
|
|
2012-04-13 10:05:32 +02:00
|
|
|
class NelmioApiDocExtension extends Extension
|
2012-04-11 20:00:21 +02:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* {@inheritdoc}
|
|
|
|
*/
|
|
|
|
public function load(array $configs, ContainerBuilder $container)
|
|
|
|
{
|
2012-04-12 20:34:19 +02:00
|
|
|
$processor = new Processor();
|
|
|
|
$configuration = new Configuration();
|
|
|
|
$config = $processor->processConfiguration($configuration, $configs);
|
|
|
|
|
|
|
|
$container->setParameter('nelmio_api_doc.api_name', $config['name']);
|
2012-07-18 13:18:26 +02:00
|
|
|
$container->setParameter('nelmio_api_doc.sandbox.enabled', $config['sandbox']['enabled']);
|
|
|
|
$container->setParameter('nelmio_api_doc.sandbox.endpoint', $config['sandbox']['endpoint']);
|
2012-04-12 20:34:19 +02:00
|
|
|
|
2012-04-11 20:00:21 +02:00
|
|
|
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
|
2012-04-12 12:50:20 +02:00
|
|
|
$loader->load('formatters.xml');
|
2012-04-11 20:00:21 +02:00
|
|
|
$loader->load('request_listener.xml');
|
|
|
|
$loader->load('services.xml');
|
2012-08-10 13:55:35 +02:00
|
|
|
|
|
|
|
if (isset($config['sandbox']['authentication'])) {
|
|
|
|
$container->setParameter('nelmio_api_doc.sandbox.authentication', $config['sandbox']['authentication']);
|
|
|
|
}
|
2012-04-11 20:00:21 +02:00
|
|
|
}
|
|
|
|
}
|