AppKernel.php 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. namespace JMS\SecurityExtraBundle\Tests\Functional;
  3. require_once __DIR__.'/../../vendor/autoload.php';
  4. use Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\FormLoginBundle\FormLoginBundle;
  5. use JMS\SecurityExtraBundle\Tests\Functional\TestBundle\TestBundle;
  6. use Symfony\Component\Filesystem\Filesystem;
  7. use Symfony\Component\Config\Loader\LoaderInterface;
  8. use Symfony\Component\HttpKernel\Kernel;
  9. class AppKernel extends Kernel
  10. {
  11. private $config;
  12. public function __construct($config)
  13. {
  14. parent::__construct('test', true);
  15. $fs = new Filesystem();
  16. if (!$fs->isAbsolutePath($config)) {
  17. $config = __DIR__.'/config/'.$config;
  18. }
  19. if (!file_exists($config)) {
  20. throw new \RuntimeException(sprintf('The config file "%s" does not exist.', $config));
  21. }
  22. $this->config = $config;
  23. }
  24. public function registerBundles()
  25. {
  26. return array(
  27. new \Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
  28. new \Symfony\Bundle\SecurityBundle\SecurityBundle(),
  29. new \Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
  30. new \Symfony\Bundle\TwigBundle\TwigBundle(),
  31. new TestBundle(),
  32. new FormLoginBundle(),
  33. new \Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
  34. new \JMS\AopBundle\JMSAopBundle(),
  35. new \JMS\DiExtraBundle\JMSDiExtraBundle($this),
  36. new \JMS\SecurityExtraBundle\JMSSecurityExtraBundle(),
  37. );
  38. }
  39. public function registerContainerConfiguration(LoaderInterface $loader)
  40. {
  41. $loader->load($this->config);
  42. }
  43. public function getCacheDir()
  44. {
  45. return sys_get_temp_dir().'/JMSSecurityExtraBundle/'.sha1($this->config);
  46. }
  47. protected function getContainerClass()
  48. {
  49. return parent::getContainerClass().sha1($this->config);
  50. }
  51. public function serialize()
  52. {
  53. return $this->config;
  54. }
  55. public function unserialize($str)
  56. {
  57. $this->__construct($str);
  58. }
  59. }