AppKernel.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <?php
  2. use Symfony\Component\HttpKernel\Kernel;
  3. use Symfony\Component\Config\Loader\LoaderInterface;
  4. use Symfony\Component\HttpKernel\HttpKernelInterface;
  5. use Symfony\Component\HttpFoundation\Request;
  6. class AppKernel extends Kernel
  7. {
  8. public function registerBundles()
  9. {
  10. $bundles = [
  11. new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
  12. new Symfony\Bundle\SecurityBundle\SecurityBundle(),
  13. new Symfony\Bundle\TwigBundle\TwigBundle(),
  14. new Symfony\Bundle\MonologBundle\MonologBundle(),
  15. new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
  16. new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
  17. new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
  18. new Sonata\CoreBundle\SonataCoreBundle(),
  19. new Sonata\BlockBundle\SonataBlockBundle(),
  20. new Knp\Bundle\MenuBundle\KnpMenuBundle(),
  21. new Sonata\DoctrineORMAdminBundle\SonataDoctrineORMAdminBundle(),
  22. new Sonata\AdminBundle\SonataAdminBundle(),
  23. new FTTHBundle\FTTHBundle(),
  24. new WebserviceBundle\WebserviceBundle(),
  25. new Voryx\RESTGeneratorBundle\VoryxRESTGeneratorBundle(),
  26. new FOS\RestBundle\FOSRestBundle(),
  27. new JMS\SerializerBundle\JMSSerializerBundle($this),
  28. new Nelmio\CorsBundle\NelmioCorsBundle(),
  29. new Base\AdminBundle\BaseAdminBundle(),
  30. new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(),
  31. new WorkflowBundle\WorkflowBundle(),
  32. new HWI\Bundle\OAuthBundle\HWIOAuthBundle(),
  33. new Base\OAuthClientBundle\BaseOAuthClientBundle(),
  34. new OldSound\RabbitMqBundle\OldSoundRabbitMqBundle(),
  35. new TemplateBundle\TemplateBundle(),
  36. new ExtraDataBundle\ExtraDataBundle(),
  37. new DeviceBundle\DeviceBundle(),
  38. new OwnerVoterBundle\OwnerVoterBundle(),
  39. new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(),
  40. new MigrationsBundle\MigrationsBundle(),
  41. new MapBundle\MapBundle(),
  42. new LeafletBundle\LeafletBundle(),
  43. new AuthBundle\AuthBundle(),
  44. new SimpleThings\EntityAudit\SimpleThingsEntityAuditBundle(),
  45. new AuditBundle\AuditBundle(),
  46. new RadiusBundle\RadiusBundle(),
  47. new TR069Bundle\TR069Bundle(),
  48. new CheckSintaxBundle\CheckSintaxBundle()
  49. ];
  50. if (in_array($this->getEnvironment(), ['dev', 'test'], true)) {
  51. $bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();
  52. $bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
  53. $bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
  54. $bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
  55. }
  56. $bundles[] = new Symfony\Bundle\WebServerBundle\WebServerBundle();
  57. return $bundles;
  58. }
  59. public function getRootDir()
  60. {
  61. return __DIR__;
  62. }
  63. public function getCacheDir()
  64. {
  65. return dirname(__DIR__) . '/var/cache/' . $this->getEnvironment();
  66. }
  67. public function getLogDir()
  68. {
  69. return dirname(__DIR__) . '/var/logs';
  70. }
  71. public function registerContainerConfiguration(LoaderInterface $loader)
  72. {
  73. $loader->load($this->getRootDir() . '/config/config_' . $this->getEnvironment() . '.yml');
  74. }
  75. /**
  76. * {@inheritdoc}
  77. */
  78. public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
  79. {
  80. if (false === $this->booted) {
  81. $this->boot();
  82. }
  83. // se puede sacar la variable nginx-proxy porque es el nombre del docker y puede variar
  84. // con REMOTRA_ADDR obtengo el mismo valor (http://symfony.com/doc/current/deployment/proxies.html)
  85. //gethostbyname("nginx-proxy") == $request->server->get('REMOTE_ADDR')
  86. if ($this->container->hasParameter("nginx_name")) {
  87. Request::setTrustedProxies(
  88. array('127.0.0.1', $this->container->getParameter("nginx_name")),
  89. Request::HEADER_X_FORWARDED_FOR);
  90. }
  91. return parent::handle($request, $type, $catch);
  92. }
  93. }