AppKernel.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. use Symfony\Component\DependencyInjection\ContainerBuilder;
  3. use Symfony\Component\HttpKernel\Kernel;
  4. use Symfony\Component\Config\Loader\LoaderInterface;
  5. class AppKernel extends Kernel
  6. {
  7. public function registerBundles()
  8. {
  9. $bundles = [
  10. new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
  11. new Symfony\Bundle\SecurityBundle\SecurityBundle(),
  12. new Symfony\Bundle\TwigBundle\TwigBundle(),
  13. new Symfony\Bundle\MonologBundle\MonologBundle(),
  14. new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
  15. new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
  16. new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
  17. new AppBundle\AppBundle(),
  18. new DocumentBundle\DocumentBundle(),
  19. ];
  20. if (in_array($this->getEnvironment(), ['dev', 'test'], true)) {
  21. $bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();
  22. $bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
  23. $bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
  24. if ('dev' === $this->getEnvironment()) {
  25. $bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
  26. $bundles[] = new Symfony\Bundle\WebServerBundle\WebServerBundle();
  27. }
  28. }
  29. return $bundles;
  30. }
  31. public function getRootDir()
  32. {
  33. return __DIR__;
  34. }
  35. public function getCacheDir()
  36. {
  37. return dirname(__DIR__).'/var/cache/'.$this->getEnvironment();
  38. }
  39. public function getLogDir()
  40. {
  41. return dirname(__DIR__).'/var/logs';
  42. }
  43. public function registerContainerConfiguration(LoaderInterface $loader)
  44. {
  45. $loader->load(function (ContainerBuilder $container) {
  46. $container->setParameter('container.autowiring.strict_mode', true);
  47. $container->setParameter('container.dumper.inline_class_loader', true);
  48. $container->addObjectResource($this);
  49. });
  50. $loader->load($this->getRootDir().'/config/config_'.$this->getEnvironment().'.yml');
  51. }
  52. }