|
1
|
|
|
<?php |
|
2
|
|
|
namespace Skrz\Bundle\AutowiringBundle; |
|
3
|
|
|
|
|
4
|
|
|
use Doctrine\Common\Annotations\AnnotationReader; |
|
5
|
|
|
use Doctrine\Common\Annotations\PhpParser; |
|
6
|
|
|
use Skrz\Bundle\AutowiringBundle\DependencyInjection\ClassMultiMap; |
|
7
|
|
|
use Skrz\Bundle\AutowiringBundle\DependencyInjection\Compiler\AutowiringCompilerPass; |
|
8
|
|
|
use Skrz\Bundle\AutowiringBundle\DependencyInjection\Compiler\ClassMapBuildCompilerPass; |
|
9
|
|
|
use Skrz\Bundle\AutowiringBundle\DependencyInjection\SkrzAutowiringExtension; |
|
10
|
|
|
use Symfony\Component\DependencyInjection\Compiler\PassConfig; |
|
11
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
12
|
|
|
use Symfony\Component\HttpKernel\Bundle\Bundle; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* @author Jakub Kulhan <[email protected]> |
|
16
|
|
|
*/ |
|
17
|
|
|
class SkrzAutowiringBundle extends Bundle |
|
18
|
|
|
{ |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* {@inheritDoc} |
|
22
|
|
|
*/ |
|
23
|
1 |
|
public function getContainerExtension() |
|
24
|
|
|
{ |
|
25
|
1 |
|
if ($this->extension === null) { |
|
26
|
1 |
|
$this->extension = new SkrzAutowiringExtension(); |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
1 |
|
return $this->extension; |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
1 |
|
public function build(ContainerBuilder $container) |
|
33
|
|
|
{ |
|
34
|
1 |
|
$annotationReader = new AnnotationReader(); |
|
35
|
1 |
|
$autowiringClassMap = new ClassMultiMap($container); |
|
36
|
|
|
|
|
37
|
1 |
|
$container->addCompilerPass( |
|
38
|
1 |
|
new ClassMapBuildCompilerPass($autowiringClassMap), |
|
39
|
1 |
|
PassConfig::TYPE_OPTIMIZE |
|
40
|
|
|
); |
|
41
|
|
|
|
|
42
|
1 |
|
$container->addCompilerPass( |
|
43
|
1 |
|
new AutowiringCompilerPass($autowiringClassMap, $annotationReader, new PhpParser()), |
|
44
|
1 |
|
PassConfig::TYPE_OPTIMIZE |
|
45
|
|
|
); |
|
46
|
1 |
|
} |
|
47
|
|
|
|
|
48
|
|
|
} |
|
49
|
|
|
|