NelmioApiDocBundle/DependencyInjection/EXSystApiDocExtension.php

60 lines
1.7 KiB
PHP
Raw Normal View History

2016-07-12 00:33:55 +02:00
<?php
/*
* This file is part of the ApiDocBundle package.
*
* (c) EXSyst
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace EXSyst\Bundle\ApiDocBundle\DependencyInjection;
2016-07-13 23:05:14 +02:00
use Nelmio\ApiDocBundle\Annotation\ApiDoc;
use phpDocumentor\Reflection\DocBlockFactory;
2016-07-28 10:20:59 +02:00
use Swagger\Annotations\Swagger;
2016-07-12 00:33:55 +02:00
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
2016-07-15 00:04:07 +02:00
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
2016-07-12 00:33:55 +02:00
class EXSystApiDocExtension extends Extension
{
/**
* {@inheritdoc}
*/
public function getAlias()
{
return 'exsyst_api_doc';
}
/**
* {@inheritdoc}
*/
public function load(array $configs, ContainerBuilder $container)
{
$config = $this->processConfiguration(new Configuration(), $configs);
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.xml');
2016-07-13 23:05:14 +02:00
2016-08-04 22:27:10 +02:00
// Import services needed for each library
if (class_exists(ApiDoc::class)) {
$loader->load('nelmio_apidoc.xml');
2016-07-13 23:05:14 +02:00
}
2016-08-04 22:27:10 +02:00
if (class_exists(DocBlockFactory::class)) {
$loader->load('php_doc.xml');
2016-07-28 10:20:59 +02:00
}
2016-08-04 22:27:10 +02:00
if (class_exists(Swagger::class)) {
$loader->load('swagger_php.xml');
2016-07-13 23:05:14 +02:00
}
2016-07-29 10:22:40 +02:00
$bundles = $container->getParameter('kernel.bundles');
// ApiPlatform support
if (isset($bundles['ApiPlatformBundle']) && class_exists('ApiPlatform\Core\Documentation\Documentation')) {
$loader->load('api_platform.xml');
}
2016-07-12 00:33:55 +02:00
}
}