-
Notifications
You must be signed in to change notification settings - Fork 1
/
interface.py
299 lines (187 loc) · 6.52 KB
/
interface.py
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
# -*- coding: utf-8 -*-
# This file is part of the pymfony package.
#
# (c) Alexandre Quercia <[email protected]>
#
# For the full copyright and license information, please view the LICENSE
# file that was distributed with this source code.
from __future__ import absolute_import;
from pymfony.component.system import Object;
from pymfony.component.system.oop import interface;
"""
"""
@interface
class ExtensionInterface(Object):
"""ExtensionInterface is the interface implemented
by container extension classes.
"""
def load(self, configs, container):
"""Loads a specific configuration.
@param configs: list An array of configuration values
@param container: ContainerBuilder A ContainerBuilder instance
@raise AttributeError: When provided tag is not defined
in this extension
"""
pass;
def getNamespace(self):
"""Returns the namespace to be used for this extension (XML namespace).
@return: string The XSD base path
"""
pass;
def getXsdValidationBasePath(self):
"""Returns the base path for the XSD files.
@return: string The XSD base path
"""
pass;
def getAlias(self):
"""Returns the recommended alias to use in XML.
This alias is also the mandatory prefix to use when using YAML.
@return: string The alias
"""
pass;
@interface
class ContainerInterface(Object):
"""ContainerInterface is the interface implemented by service container classes.
@author Fabien Potencier <[email protected]>
@author Johannes M. Schmitt <[email protected]>
@api
"""
EXCEPTION_ON_INVALID_REFERENCE = 1;
NULL_ON_INVALID_REFERENCE = 2;
IGNORE_ON_INVALID_REFERENCE = 3;
SCOPE_CONTAINER = 'container';
SCOPE_PROTOTYPE = 'prototype';
def set(self, identifier, service, scope = SCOPE_CONTAINER):
"""Sets a service.
@param string identifier The service identifier:
@param object service The service instance
@param string scope The scope of the service
@api
"""
def get(self, identifier, invalidBehavior = EXCEPTION_ON_INVALID_REFERENCE):
"""Gets a service.
@param string identifier The service identifier:
@param int invalidBehavior The behavior when the service does not exist
@return object The associated service
@raise InvalidArgumentException if the service is not defined:
@raise ServiceCircularReferenceException When a circular reference is detected
@raise ServiceNotFoundException When the service is not defined
@see Reference
@api
"""
def has(self, identifier):
"""Returns True if the given service is defined.:
@param string identifier The service identifier:
@return Boolean True if the service is defined, False otherwise:
@api
"""
def getParameter(self, name):
"""Gets a parameter.
@param string name The parameter name
@return mixed The parameter value
@raise InvalidArgumentException if the parameter is not defined:
@api
"""
def hasParameter(self, name):
"""Checks if a parameter exists.:
@param string name The parameter name
@return Boolean The presence of parameter in container
@api
"""
def setParameter(self, name, value):
"""Sets a parameter.
@param string name The parameter name
@param mixed value The parameter value
@api
"""
def enterScope(self, name):
"""Enters the given scope
@param string name
@api
"""
def leaveScope(self, name):
"""Leaves the current scope, and re-enters the parent scope
@param string name
@api
"""
def addScope(self, scope):
"""Adds a scope to the container
@param ScopeInterface scope
@api
"""
assert isinstance(scope, ScopeInterface);
def hasScope(self, name):
"""Whether this container has the given scope
@param string name
@return Boolean
@api
"""
def isScopeActive(self, name):
"""Determines whether the given scope is currently active.
It does however not check if the scope actually exists.:
@param string name
@return Boolean
@api
"""
@interface
class ContainerAwareInterface(Object):
def setContainer(self, container):
"""Sets the Container.
@param container: ContainerInterface A ContainerInterface instance
"""
pass;
@interface
class TaggedContainerInterface(ContainerInterface):
"""TaggedContainerInterface is the interface implemented when a
container knows how to deals with tags.
"""
def findTaggedServiceIds(self, name):
"""Returns service ids for a given tag.
@param name: string The tag name
@return: dict An array of tags
"""
pass;
@interface
class IntrospectableContainerInterface(ContainerInterface):
"""IntrospectableContainerInterface defines additional introspection functionality
for containers, allowing logic to be implemented based on a Container's state.
@author: Evan Villemez <[email protected]>
"""
def initialized(self, identifier):
"""Check for whether or not a service has been initialized.
@param: string identifier
@return: Boolean True if the service has been initialized, False otherwise
"""
@interface
class ScopeInterface(Object):
"""Scope Interface.
@author Johannes M. Schmitt <[email protected]>
@api
"""
def getName(self):
"""
@api
"""
def getParentName(self):
"""
@api
"""
@interface
class CompilerPassInterface(Object):
"""Interface that must be implemented by compilation passes
"""
def process(self, container):
"""You can modify the container here before it is dumped to PHP code.
@param container: ContainerBuilder
"""
pass;
@interface
class RepeatablePassInterface(CompilerPassInterface):
"""Interface that must be implemented by passes that are run as part of an
RepeatedPass.
@author Johannes M. Schmitt <[email protected]>
"""
def setRepeatedPass(self, repeatedPass):
"""Sets the RepeatedPass interface.
@param RepeatedPass repeatedPass
"""