forked from 8p/EightPointsGuzzleBundle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GuzzleBundle.php
65 lines (53 loc) · 1.6 KB
/
GuzzleBundle.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
<?php
namespace EightPoints\Bundle\GuzzleBundle;
use EightPoints\Bundle\GuzzleBundle\DependencyInjection\GuzzleExtension;
use EightPoints\Bundle\GuzzleBundle\DependencyInjection\Compiler\EventHandlerCompilerPass;
use Symfony\Component\HttpKernel\Bundle\Bundle;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
/**
* @version 1.0
* @since 2013-10
*/
class GuzzleBundle extends Bundle
{
/**
* Build GuzzleBundle
*
* @version 1.0
* @since 2013-10
*
* @param ContainerBuilder $container
* @return void
*/
public function build(ContainerBuilder $container)
{
parent::build($container);
$container->addCompilerPass(new EventHandlerCompilerPass());
}
/**
* Overwrite getContainerExtension
* - no naming convention of alias needed
* - extension class can be moved easily now
*
* @see getContainerExtension
*
* @version 1.1
* @since 2013-12
*
* @return ExtensionInterface|null The container extension
* @throws \LogicException
*/
public function getContainerExtension()
{
if (null === $this->extension) {
$extension = new GuzzleExtension();
if (!$extension instanceof ExtensionInterface) {
$message = sprintf('%s is not a instance of ExtensionInterface', $extension->getClass());
throw new \LogicException($message);
}
$this->extension = $extension;
}
return $this->extension;
}
}