| 1 | <?php |
||
| 9 | class AppKernel extends Kernel |
||
| 10 | { |
||
| 11 | private $config; |
||
| 12 | |||
| 13 | public function __construct($config) |
||
| 14 | { |
||
| 15 | parent::__construct('test', true); |
||
| 16 | |||
| 17 | $fs = new Filesystem(); |
||
| 18 | |||
| 19 | if (!$fs->isAbsolutePath($config)) { |
||
| 20 | $config = __DIR__.'/config/'.$config; |
||
| 21 | } |
||
| 22 | |||
| 23 | if (!file_exists($config)) { |
||
| 24 | throw new \RuntimeException(sprintf('The config file "%s" does not exist', $config)); |
||
| 25 | } |
||
| 26 | |||
| 27 | $this->config = $config; |
||
| 28 | } |
||
| 29 | |||
| 30 | public function registerBundles() |
||
| 31 | { |
||
| 32 | return [ |
||
| 33 | new \Symfony\Bundle\FrameworkBundle\FrameworkBundle(), |
||
| 34 | new \Happyr\GoogleAnalyticsBundle\HappyrGoogleAnalyticsBundle(), |
||
| 35 | ]; |
||
| 36 | } |
||
| 37 | |||
| 38 | public function registerContainerConfiguration(LoaderInterface $loader) |
||
| 39 | { |
||
| 40 | $loader->load($this->config); |
||
| 41 | } |
||
| 42 | |||
| 43 | public function getCacheDir() |
||
| 44 | { |
||
| 45 | return sys_get_temp_dir().'/TestBundle'; |
||
| 46 | } |
||
| 47 | |||
| 48 | public function serialize() |
||
| 49 | { |
||
| 50 | return $this->config; |
||
| 51 | } |
||
| 52 | |||
| 53 | public function unserialize($config) |
||
| 54 | { |
||
| 55 | $this->__construct($config); |
||
| 56 | } |
||
| 57 | } |
||
| 58 |