AppKernel.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. ];
  19. if (in_array($this->getEnvironment(), ['dev', 'test'], true)) {
  20. $bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();
  21. $bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
  22. $bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
  23. if ('dev' === $this->getEnvironment()) {
  24. $bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
  25. $bundles[] = new Symfony\Bundle\WebServerBundle\WebServerBundle();
  26. }
  27. }
  28. return $bundles;
  29. }
  30. public function getRootDir()
  31. {
  32. return __DIR__;
  33. }
  34. public function getCacheDir()
  35. {
  36. return dirname(__DIR__).'/var/cache/'.$this->getEnvironment();
  37. }
  38. public function getLogDir()
  39. {
  40. return dirname(__DIR__).'/var/logs';
  41. }
  42. public function registerContainerConfiguration(LoaderInterface $loader)
  43. {
  44. $loader->load(function (ContainerBuilder $container) {
  45. $container->setParameter('container.autowiring.strict_mode', true);
  46. $container->setParameter('container.dumper.inline_class_loader', true);
  47. $container->addObjectResource($this);
  48. });
  49. $loader->load($this->getRootDir().'/config/config_'.$this->getEnvironment().'.yml');
  50. }
  51. }