-
Notifications
You must be signed in to change notification settings - Fork 125
/
AdmingeneratorGeneratorBundle.php
68 lines (57 loc) · 1.98 KB
/
AdmingeneratorGeneratorBundle.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
namespace Admingenerator\GeneratorBundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Admingenerator\GeneratorBundle\ClassLoader\AdmingeneratedClassLoader;
use Admingenerator\GeneratorBundle\DependencyInjection\Compiler\ValidatorCompilerPass;
use Admingenerator\GeneratorBundle\DependencyInjection\Compiler\FormCompilerPass;
class AdmingeneratorGeneratorBundle extends Bundle
{
/**
* @var boolean
*/
private $classLoaderInitialized = false;
/**
* (non-PHPdoc)
* @see \Symfony\Component\HttpKernel\Bundle\Bundle::boot()
*/
public function boot()
{
$this->initAdmingeneratorClassLoader($this->container);
}
/**
* (non-PHPdoc)
* @see \Symfony\Component\HttpKernel\Bundle\Bundle::build()
*/
public function build(ContainerBuilder $container)
{
$this->initAdmingeneratorClassLoader($container);
parent::build($container);
$container->addCompilerPass(new ValidatorCompilerPass());
$container->addCompilerPass(new FormCompilerPass());
}
/**
* (non-PHPdoc)
* @see \Symfony\Component\HttpKernel\Bundle\Bundle::getContainerExtension()
*/
public function getContainerExtension()
{
$this->extension = new DependencyInjection\AdmingeneratorGeneratorExtension();
return $this->extension;
}
/**
* Initialize Admingenerator Class loader
*
* @param ContainerBuilder $container
*/
private function initAdmingeneratorClassLoader(ContainerInterface $container)
{
if (!$this->classLoaderInitialized) {
$this->classLoaderInitialized = true;
$AdmingeneratedClassLoader = new AdmingeneratedClassLoader();
$AdmingeneratedClassLoader->setBasePath($container->getParameter('kernel.cache_dir'));
$AdmingeneratedClassLoader->register();
}
}
}