vendor/nelmio/api-doc-bundle/src/NelmioApiDocBundle.php line 21

  1. <?php
  2. /*
  3.  * This file is part of the NelmioApiDocBundle package.
  4.  *
  5.  * (c) Nelmio
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace Nelmio\ApiDocBundle;
  11. use Nelmio\ApiDocBundle\DependencyInjection\Compiler\ConfigurationPass;
  12. use Nelmio\ApiDocBundle\DependencyInjection\Compiler\CustomProcessorPass;
  13. use Nelmio\ApiDocBundle\DependencyInjection\Compiler\PhpDocExtractorPass;
  14. use Nelmio\ApiDocBundle\DependencyInjection\Compiler\TagDescribersPass;
  15. use Symfony\Component\DependencyInjection\ContainerBuilder;
  16. use Symfony\Component\HttpKernel\Bundle\Bundle;
  17. final class NelmioApiDocBundle extends Bundle
  18. {
  19.     /**
  20.      * {@inheritdoc}
  21.      */
  22.     public function build(ContainerBuilder $container): void
  23.     {
  24.         $container->addCompilerPass(new ConfigurationPass());
  25.         $container->addCompilerPass(new TagDescribersPass());
  26.         $container->addCompilerPass(new PhpDocExtractorPass());
  27.         $container->addCompilerPass(new CustomProcessorPass());
  28.     }
  29.     /**
  30.      * Allows using the new directory structure on Symfony < 6.1.
  31.      * Without this no proper namespace is set for twig templates.
  32.      *
  33.      * @see \Symfony\Component\HttpKernel\Bundle\AbstractBundle::getPath()
  34.      */
  35.     public function getPath(): string
  36.     {
  37.         if (!isset($this->path)) {
  38.             $reflected = new \ReflectionObject($this);
  39.             // assume the modern directory structure by default
  40.             $this->path \dirname($reflected->getFileName(), 2);
  41.         }
  42.         return $this->path;
  43.     }
  44. }