|
1 <?php |
|
2 |
|
3 /* |
|
4 * This file is part of the Symfony package. |
|
5 * |
|
6 * (c) Fabien Potencier <fabien@symfony.com> |
|
7 * |
|
8 * For the full copyright and license information, please view the LICENSE |
|
9 * file that was distributed with this source code. |
|
10 */ |
|
11 |
|
12 namespace Symfony\Component\DependencyInjection; |
|
13 |
|
14 /** |
|
15 * ContainerInterface is the interface implemented by service container classes. |
|
16 * |
|
17 * @author Fabien Potencier <fabien@symfony.com> |
|
18 * @author Johannes M. Schmitt <schmittjoh@gmail.com> |
|
19 * |
|
20 * @api |
|
21 */ |
|
22 interface ContainerInterface |
|
23 { |
|
24 const EXCEPTION_ON_INVALID_REFERENCE = 1; |
|
25 const NULL_ON_INVALID_REFERENCE = 2; |
|
26 const IGNORE_ON_INVALID_REFERENCE = 3; |
|
27 const SCOPE_CONTAINER = 'container'; |
|
28 const SCOPE_PROTOTYPE = 'prototype'; |
|
29 |
|
30 /** |
|
31 * Sets a service. |
|
32 * |
|
33 * @param string $id The service identifier |
|
34 * @param object $service The service instance |
|
35 * @param string $scope The scope of the service |
|
36 * |
|
37 * @api |
|
38 */ |
|
39 function set($id, $service, $scope = self::SCOPE_CONTAINER); |
|
40 |
|
41 /** |
|
42 * Gets a service. |
|
43 * |
|
44 * @param string $id The service identifier |
|
45 * @param int $invalidBehavior The behavior when the service does not exist |
|
46 * |
|
47 * @return object The associated service |
|
48 * |
|
49 * @throws \InvalidArgumentException if the service is not defined |
|
50 * |
|
51 * @see Reference |
|
52 * |
|
53 * @api |
|
54 */ |
|
55 function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE); |
|
56 |
|
57 /** |
|
58 * Returns true if the given service is defined. |
|
59 * |
|
60 * @param string $id The service identifier |
|
61 * |
|
62 * @return Boolean true if the service is defined, false otherwise |
|
63 * |
|
64 * @api |
|
65 */ |
|
66 function has($id); |
|
67 |
|
68 /** |
|
69 * Gets a parameter. |
|
70 * |
|
71 * @param string $name The parameter name |
|
72 * |
|
73 * @return mixed The parameter value |
|
74 * |
|
75 * @throws \InvalidArgumentException if the parameter is not defined |
|
76 * |
|
77 * @api |
|
78 */ |
|
79 function getParameter($name); |
|
80 |
|
81 /** |
|
82 * Checks if a parameter exists. |
|
83 * |
|
84 * @param string $name The parameter name |
|
85 * |
|
86 * @return Boolean The presence of parameter in container |
|
87 * |
|
88 * @api |
|
89 */ |
|
90 function hasParameter($name); |
|
91 |
|
92 /** |
|
93 * Sets a parameter. |
|
94 * |
|
95 * @param string $name The parameter name |
|
96 * @param mixed $value The parameter value |
|
97 * |
|
98 * @api |
|
99 */ |
|
100 function setParameter($name, $value); |
|
101 |
|
102 /** |
|
103 * Enters the given scope |
|
104 * |
|
105 * @param string $name |
|
106 * @return void |
|
107 * |
|
108 * @api |
|
109 */ |
|
110 function enterScope($name); |
|
111 |
|
112 /** |
|
113 * Leaves the current scope, and re-enters the parent scope |
|
114 * |
|
115 * @param string $name |
|
116 * @return void |
|
117 * |
|
118 * @api |
|
119 */ |
|
120 function leaveScope($name); |
|
121 |
|
122 /** |
|
123 * Adds a scope to the container |
|
124 * |
|
125 * @param ScopeInterface $scope |
|
126 * @return void |
|
127 * |
|
128 * @api |
|
129 */ |
|
130 function addScope(ScopeInterface $scope); |
|
131 |
|
132 /** |
|
133 * Whether this container has the given scope |
|
134 * |
|
135 * @param string $name |
|
136 * @return Boolean |
|
137 * |
|
138 * @api |
|
139 */ |
|
140 function hasScope($name); |
|
141 |
|
142 /** |
|
143 * Determines whether the given scope is currently active. |
|
144 * |
|
145 * It does however not check if the scope actually exists. |
|
146 * |
|
147 * @param string $name |
|
148 * @return Boolean |
|
149 * |
|
150 * @api |
|
151 */ |
|
152 function isScopeActive($name); |
|
153 } |