Bundle.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace Symfony\Framework\PropelBundle;
  3. use Symfony\Foundation\Bundle\Bundle as BaseBundle;
  4. use Symfony\Components\DependencyInjection\ContainerInterface;
  5. use Symfony\Components\DependencyInjection\Loader\Loader;
  6. use Symfony\Components\DependencyInjection\Loader\XmlFileLoader;
  7. use Symfony\Framework\PropelBundle\DependencyInjection\PropelExtension;
  8. class Bundle extends BaseBundle
  9. {
  10. public function buildContainer(ContainerInterface $container)
  11. {
  12. Loader::registerExtension(new PropelExtension());
  13. }
  14. public function boot(ContainerInterface $container)
  15. {
  16. require_once $container->getParameter('propel.path').'/runtime/lib/Propel.php';
  17. if (0 === strncasecmp(PHP_SAPI, 'cli', 3)) {
  18. set_include_path($container->getParameter('propel.phing_path').'/classes'.PATH_SEPARATOR.get_include_path());
  19. }
  20. $kernel = $container->getKernelService();
  21. if (!file_exists($autoload = $kernel->getCacheDir().'/propel_autoload.php')) {
  22. $map = array();
  23. foreach ($kernel->getBundles() as $bundle) {
  24. if (!file_exists($file = $bundle->getPath().'/Resources/config/classmap.php')) {
  25. continue;
  26. }
  27. $local = include($file);
  28. foreach ($local as $class => $path) {
  29. $map[$class] = $bundle->getPath().'/'.$path;
  30. }
  31. }
  32. file_put_contents($autoload, '<?php return '.var_export($map, true).';');
  33. }
  34. $autoloader = \PropelAutoloader::getInstance();
  35. $autoloader->addClassPaths(include($autoload));
  36. $autoloader->register();
  37. }
  38. }