AppKernel.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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 RadiusBundle\RadiusBundle(),
  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 CheckSintaxBundle\CheckSintaxBundle()
  47. ];
  48. if (in_array($this->getEnvironment(), ['dev', 'test'], true)) {
  49. $bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();
  50. $bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
  51. $bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
  52. $bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
  53. }
  54. $bundles[] = new Symfony\Bundle\WebServerBundle\WebServerBundle();
  55. return $bundles;
  56. }
  57. public function getRootDir()
  58. {
  59. return __DIR__;
  60. }
  61. public function getCacheDir()
  62. {
  63. return dirname(__DIR__) . '/var/cache/' . $this->getEnvironment();
  64. }
  65. public function getLogDir()
  66. {
  67. return dirname(__DIR__) . '/var/logs';
  68. }
  69. public function registerContainerConfiguration(LoaderInterface $loader)
  70. {
  71. $loader->load($this->getRootDir() . '/config/config_' . $this->getEnvironment() . '.yml');
  72. }
  73. /**
  74. * {@inheritdoc}
  75. */
  76. public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
  77. {
  78. if (false === $this->booted) {
  79. $this->boot();
  80. }
  81. // se puede sacar la variable nginx-proxy porque es el nombre del docker y puede variar
  82. // con REMOTRA_ADDR obtengo el mismo valor (http://symfony.com/doc/current/deployment/proxies.html)
  83. //gethostbyname("nginx-proxy") == $request->server->get('REMOTE_ADDR')
  84. if ($this->container->hasParameter("nginx_name")) {
  85. Request::setTrustedProxies(
  86. array('127.0.0.1', $this->container->getParameter("nginx_name")),
  87. Request::HEADER_X_FORWARDED_FOR);
  88. }
  89. return parent::handle($request, $type, $catch);
  90. }
  91. }