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