ConcreteMicroKernel.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Bundle\FrameworkBundle\Tests\Kernel;
  11. use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
  12. use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
  13. use Symfony\Component\Config\Loader\LoaderInterface;
  14. use Symfony\Component\DependencyInjection\ContainerBuilder;
  15. use Symfony\Component\Filesystem\Filesystem;
  16. use Symfony\Component\HttpFoundation\Response;
  17. use Symfony\Component\HttpKernel\Kernel;
  18. use Symfony\Component\Routing\RouteCollectionBuilder;
  19. class ConcreteMicroKernel extends Kernel
  20. {
  21. use MicroKernelTrait;
  22. private $cacheDir;
  23. public function halloweenAction()
  24. {
  25. return new Response('halloween');
  26. }
  27. public function registerBundles()
  28. {
  29. return array(
  30. new FrameworkBundle(),
  31. );
  32. }
  33. public function getCacheDir()
  34. {
  35. return $this->cacheDir = sys_get_temp_dir().'/sf_micro_kernel';
  36. }
  37. public function getLogDir()
  38. {
  39. return $this->cacheDir;
  40. }
  41. public function __destruct()
  42. {
  43. $fs = new Filesystem();
  44. $fs->remove($this->cacheDir);
  45. }
  46. protected function configureRoutes(RouteCollectionBuilder $routes)
  47. {
  48. $routes->add('/', 'kernel:halloweenAction');
  49. }
  50. protected function configureContainer(ContainerBuilder $c, LoaderInterface $loader)
  51. {
  52. $c->loadFromExtension('framework', array(
  53. 'secret' => '$ecret',
  54. ));
  55. $c->setParameter('halloween', 'Have a great day!');
  56. $c->register('halloween', 'stdClass');
  57. }
  58. }