Révision 950416da
Ajouté par Assos Assos il y a plus de 5 ans
drupal7/sites/all/modules/rules/includes/faces.inc | ||
---|---|---|
1 | 1 |
<?php |
2 | 2 |
|
3 | 3 |
/** |
4 |
* @file Extendable Object Faces API. Provided by the faces module. |
|
4 |
* @file |
|
5 |
* Extendable Object Faces API. Provided by the faces module. |
|
5 | 6 |
*/ |
6 | 7 |
|
7 | 8 |
if (!interface_exists('FacesExtenderInterface', FALSE)) { |
... | ... | |
14 | 15 |
/** |
15 | 16 |
* Constructs an instance of the extender. |
16 | 17 |
*/ |
17 |
function __construct(FacesExtendable $object); |
|
18 |
public function __construct(FacesExtendable $object);
|
|
18 | 19 |
|
19 | 20 |
/** |
20 | 21 |
* Returns the extended object. |
21 | 22 |
*/ |
22 | 23 |
public function getExtendable(); |
24 |
|
|
23 | 25 |
} |
24 | 26 |
|
25 | 27 |
/** |
... | ... | |
31 | 33 |
|
32 | 34 |
if (!class_exists('FacesExtender', FALSE)) { |
33 | 35 |
/** |
34 |
* A common base class for FacesExtenders. Extenders may access protected |
|
35 |
* methods and properties of the extendable using the property() and call() |
|
36 |
* methods. |
|
36 |
* A common base class for FacesExtenders. |
|
37 |
* |
|
38 |
* Extenders may access protected methods and properties of the extendable |
|
39 |
* using the property() and call() methods. |
|
37 | 40 |
*/ |
38 | 41 |
abstract class FacesExtender implements FacesExtenderInterface { |
39 | 42 |
|
... | ... | |
42 | 45 |
*/ |
43 | 46 |
protected $object; |
44 | 47 |
|
45 |
|
|
46 |
function __construct(FacesExtendable $object) { |
|
48 |
public function __construct(FacesExtendable $object) { |
|
47 | 49 |
$this->object = $object; |
48 | 50 |
} |
49 | 51 |
|
... | ... | |
63 | 65 |
} |
64 | 66 |
|
65 | 67 |
/** |
66 |
* Invokes any method on the extended object. May be used to invoke |
|
67 |
* protected methods. |
|
68 |
* Invokes any method on the extended object, including protected methods. |
|
68 | 69 |
* |
69 |
* @param $name |
|
70 |
* @param string $name
|
|
70 | 71 |
* The method name. |
71 |
* @param $arguments
|
|
72 |
* @param array $args
|
|
72 | 73 |
* An array of arguments to pass to the method. |
73 | 74 |
*/ |
74 | 75 |
protected function call($name, array $args = array()) { |
75 | 76 |
return $this->object->call($name, $args); |
76 | 77 |
} |
78 |
|
|
77 | 79 |
} |
78 | 80 |
} |
79 | 81 |
|
... | ... | |
108 | 110 |
/** |
109 | 111 |
* Magic method: Invoke the dynamically implemented methods. |
110 | 112 |
*/ |
111 |
function __call($name, $arguments = array()) { |
|
113 |
public function __call($name, $arguments = array()) {
|
|
112 | 114 |
if (isset($this->facesMethods[$name])) { |
113 | 115 |
$method = $this->facesMethods[$name]; |
114 | 116 |
// Include code, if necessary. |
... | ... | |
134 | 136 |
} |
135 | 137 |
|
136 | 138 |
/** |
137 |
* Returns the extender object for the given class. May be used to |
|
138 |
* explicitly invoke a specific extender, e.g. a function overriding a |
|
139 |
* method may use that to explicitly invoke the original extender. |
|
139 |
* Returns the extender object for the given class. |
|
140 |
* |
|
141 |
* May be used to explicitly invoke a specific extender, e.g. a function |
|
142 |
* overriding a method may use that to explicitly invoke the original |
|
143 |
* extender. |
|
140 | 144 |
*/ |
141 | 145 |
public function extender($class) { |
142 | 146 |
if (!isset($this->facesClassInstances[$class])) { |
... | ... | |
146 | 150 |
} |
147 | 151 |
|
148 | 152 |
/** |
153 |
* Returns whether the object can face as the given interface. |
|
154 |
* |
|
149 | 155 |
* Returns whether the object can face as the given interface, thus it |
150 |
* returns TRUE if this oject has been extended by an appropriate |
|
156 |
* returns TRUE if this object has been extended by an appropriate
|
|
151 | 157 |
* implementation. |
152 | 158 |
* |
153 | 159 |
* @param $interface |
154 |
* Optional. A interface to test for. If it's omitted, all interfaces that |
|
155 |
* the object can be faced as are returned. |
|
156 |
* @return |
|
160 |
* Optional. An interface to test for. If it's omitted, all interfaces |
|
161 |
* that the object can be faced as are returned. |
|
162 |
* |
|
163 |
* @return bool |
|
157 | 164 |
* Whether the object can face as the interface or an array of interface |
158 | 165 |
* names. |
159 | 166 |
*/ |
... | ... | |
169 | 176 |
* |
170 | 177 |
* @param $interface |
171 | 178 |
* The interface name or an array of interface names. |
172 |
* @param $class |
|
179 |
* @param $className
|
|
173 | 180 |
* The extender class, which has to implement the FacesExtenderInterface. |
174 |
* @param $include
|
|
181 |
* @param array $includes
|
|
175 | 182 |
* An optional array describing the file to include before invoking the |
176 | 183 |
* class. The array entries known are 'type', 'module', and 'name' |
177 | 184 |
* matching the parameters of module_load_include(). Only 'module' is |
... | ... | |
206 | 213 |
* @param $interface |
207 | 214 |
* The interface name or FALSE to extend the object without a given |
208 | 215 |
* interface. |
209 |
* @param $methods
|
|
216 |
* @param array $callbacks
|
|
210 | 217 |
* An array, where the keys are methods of the given interface and the |
211 | 218 |
* values the callback functions to use. |
212 |
* @param $includes |
|
219 |
* @param array $includes
|
|
213 | 220 |
* An optional array to describe files to include before invoking the |
214 | 221 |
* callbacks. You may pass a single array describing one include for all |
215 | 222 |
* callbacks or an array of arrays, keyed by the method names. Look at the |
... | ... | |
234 | 241 |
/** |
235 | 242 |
* Override the implementation of an extended method. |
236 | 243 |
* |
237 |
* @param $methods
|
|
238 |
* An array of methods of the interface, that should be overriden, where |
|
244 |
* @param array $callbacks
|
|
245 |
* An array of methods of the interface, that should be overridden, where
|
|
239 | 246 |
* the keys are methods to override and the values the callback functions |
240 | 247 |
* to use. |
241 |
* @param $includes |
|
248 |
* @param array $includes
|
|
242 | 249 |
* An optional array to describe files to include before invoking the |
243 | 250 |
* callbacks. You may pass a single array describing one include for all |
244 | 251 |
* callbacks or an array of arrays, keyed by the method names. Look at the |
... | ... | |
257 | 264 |
|
258 | 265 |
/** |
259 | 266 |
* Adds in include files for the given methods while removing any old files. |
267 |
* |
|
260 | 268 |
* If a single include file is described, it's added for all methods. |
261 | 269 |
*/ |
262 | 270 |
protected function addIncludes($methods, $includes) { |
... | ... | |
272 | 280 |
} |
273 | 281 |
|
274 | 282 |
/** |
283 |
* Destroys all references to created instances. |
|
284 |
* |
|
275 | 285 |
* Destroys all references to created instances so that PHP's garbage |
276 | 286 |
* collection can do its work. This is needed as PHP's gc has troubles with |
277 | 287 |
* circular references until PHP < 5.3. |
... | ... | |
296 | 306 |
* This also allows to pass arguments by reference, so it may be used to |
297 | 307 |
* pass arguments by reference to dynamically extended methods. |
298 | 308 |
* |
299 |
* @param $name |
|
309 |
* @param string $name
|
|
300 | 310 |
* The method name. |
301 |
* @param $arguments
|
|
311 |
* @param array $args
|
|
302 | 312 |
* An array of arguments to pass to the method. |
303 | 313 |
*/ |
304 | 314 |
public function call($name, array $args = array()) { |
... | ... | |
307 | 317 |
} |
308 | 318 |
return $this->__call($name, $args); |
309 | 319 |
} |
320 |
|
|
310 | 321 |
} |
311 |
} |
|
322 |
|
|
323 |
} |
Formats disponibles : Unified diff
Weekly update of contrib modules