-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathBaseExtension.php
107 lines (97 loc) · 2.22 KB
/
BaseExtension.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<?php
/*
* This file is part of the OverblogThriftBundle package.
*
* (c) Overblog <http://github.com/overblog/>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Symfony extension for Thrift Extension.
*
* @category Bundle
*
* @author Vincent Bouzeran <[email protected]>
* @author Yannick Le Guédart <[email protected]>
* @copyright 2011 Overblog
*/
namespace Overblog\ThriftBundle\Api\Extensions;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Symfony extension for Thrift Extension.
*
* @category Bundle
*
* @author Vincent Bouzeran <[email protected]>
* @author Yannick Le Guédart <[email protected]>
*/
abstract class BaseExtension
{
/**
* Injected SF2 container.
*
* @var type
*/
protected $_container;
/**
* Thrift Factory.
*
* @var type
*/
protected $factory;
/**
* Constructor.
*
* @param ContainerInterface $container
*/
public function __construct(ContainerInterface $container)
{
$this->_container = $container;
$this->factory = $container->get('thrift.factory');
}
/**
* Returns a service from the injected container.
*
* @param string $service
*
* @return mixed
*/
public function get($service)
{
return $this->_container->get($service);
}
/**
* Set a service to the injected container.
*
* @param string $id, The service id
* @param mixed $service, The service
*/
public function set($id, $service)
{
$this->_container->set($id, $service);
}
/**
* Returns a parameter from the injected container.
*
* @param string $name
*
* @return mixed
*/
public function getParameter($name)
{
return $this->_container->getParameter($name);
}
/**
* Get instance of Thrift Model classes.
*
* @param string $class
* @param mixed $param
*
* @return mixed
*/
public function getInstance($class, $param = null)
{
return $this->factory->getInstance($class, $param);
}
}