diff --git a/tests/coverage/Doctrine.html b/tests/coverage/Doctrine.html index b34dd194c..6563b9cc6 100644 --- a/tests/coverage/Doctrine.html +++ b/tests/coverage/Doctrine.html @@ -16,7 +16,7 @@
1 | -<?php + | <?php |
2 | -/* + | /* |
3 | -* $Id: Configurable.php 3059 2007-11-01 23:03:32Z zYne $ + | * $Id: Configurable.php 3067 2007-11-02 16:59:20Z phuson $ |
4 | -* + | * |
5 | -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
6 | -* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
7 | -* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
8 | -* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
9 | -* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
10 | -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
11 | -* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
12 | -* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
13 | -* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
14 | -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
15 | -* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
16 | -* + | * |
17 | -* This software consists of voluntary contributions made by many individuals + | * This software consists of voluntary contributions made by many individuals |
18 | -* and is licensed under the LGPL. For more information, see + | * and is licensed under the LGPL. For more information, see |
19 | -* <http://www.phpdoctrine.com>. + | * <http://www.phpdoctrine.com>. |
20 | -*/ + | */ |
21 | -+ | |
22 | -/** + | /** |
23 | -* Doctrine_Configurable + | * Doctrine_Configurable |
24 | -* the base for Doctrine_Table, Doctrine_Manager and Doctrine_Connection + | * the base for Doctrine_Table, Doctrine_Manager and Doctrine_Connection |
25 | -* + | * |
26 | -* + | * |
27 | -* @package Doctrine + | * @package Doctrine |
28 | -* @subpackage Configurable + | * @subpackage Configurable |
29 | -* @license http://www.opensource.org/licenses/lgpl-license.php LGPL + | * @license http://www.opensource.org/licenses/lgpl-license.php LGPL |
30 | -* @link www.phpdoctrine.com + | * @link www.phpdoctrine.com |
31 | -* @since 1.0 + | * @since 1.0 |
32 | -* @version $Revision: 3059 $ + | * @version $Revision: 3067 $ |
33 | -* @author Konsta Vesterinen <kvesteri@cc.hut.fi> + | * @author Konsta Vesterinen <kvesteri@cc.hut.fi> |
34 | -*/ + | */ |
35 | -abstract class Doctrine_Configurable extends Doctrine_Locator_Injectable + | abstract class Doctrine_Configurable extends Doctrine_Locator_Injectable |
36 | -{ + | { |
37 | -/** + | /** |
38 | -* @var array $attributes an array of containing all attributes + | * @var array $attributes an array of containing all attributes |
39 | -*/ + | */ |
40 | -protected $attributes = array(); + | protected $attributes = array(); |
41 | -+ | |
42 | -/** + | /** |
43 | -* @var Doctrine_Configurable $parent the parent of this component + | * @var Doctrine_Configurable $parent the parent of this component |
44 | -*/ + | */ |
45 | -protected $parent; + | protected $parent; |
46 | -+ | |
47 | -/** + | /** |
48 | -* @var array $_impl an array containing concrete implementations for class templates + | * @var array $_impl an array containing concrete implementations for class templates |
49 | -* keys as template names and values as names of the concrete + | * keys as template names and values as names of the concrete |
50 | -* implementation classes + | * implementation classes |
51 | -*/ + | */ |
52 | -protected $_impl = array(); + | protected $_impl = array(); |
53 | -+ | |
54 | -/** + | /** |
55 | -* @var array $_params an array of user defined parameters + | * @var array $_params an array of user defined parameters |
56 | -*/ + | */ |
57 | -protected $_params = array(); + | protected $_params = array(); |
58 | -+ | |
59 | -/** + | /** |
60 | -* setAttribute + | * setAttribute |
61 | -* sets a given attribute + | * sets a given attribute |
62 | -* + | * |
63 | -* <code> + | * <code> |
64 | -* $manager->setAttribute(Doctrine::ATTR_PORTABILITY, Doctrine::PORTABILITY_ALL); + | * $manager->setAttribute(Doctrine::ATTR_PORTABILITY, Doctrine::PORTABILITY_ALL); |
65 | -* + | * |
66 | -* // or + | * // or |
67 | -* + | * |
68 | -* $manager->setAttribute('portability', Doctrine::PORTABILITY_ALL); + | * $manager->setAttribute('portability', Doctrine::PORTABILITY_ALL); |
69 | -* </code> + | * </code> |
70 | -* + | * |
71 | -* @param mixed $attribute either a Doctrine::ATTR_* integer constant or a string + | * @param mixed $attribute either a Doctrine::ATTR_* integer constant or a string |
72 | -* corresponding to a constant + | * corresponding to a constant |
73 | -* @param mixed $value the value of the attribute + | * @param mixed $value the value of the attribute |
74 | -* @see Doctrine::ATTR_* constants + | * @see Doctrine::ATTR_* constants |
75 | -* @throws Doctrine_Exception if the value is invalid + | * @throws Doctrine_Exception if the value is invalid |
76 | -* @return void + | * @return void |
77 | -*/ + | */ |
78 | -public function setAttribute($attribute,$value) + | public function setAttribute($attribute,$value) |
79 | -{ + | { |
80 | -if (is_string($attribute)) { + | if (is_string($attribute)) { |
81 | -$upper = strtoupper($attribute); + | $upper = strtoupper($attribute); |
82 | -+ | |
83 | -$const = 'Doctrine::ATTR_' . $attribute; + | $const = 'Doctrine::ATTR_' . $attribute; |
84 | -if (defined($const)) { + | if (defined($const)) { |
85 | -$this->_state = constant($const); + | $this->_state = constant($const); |
86 | -} else { + | } else { |
87 | -throw new Doctrine_Exception('Unknown attribute ' . $attribute); + | throw new Doctrine_Exception('Unknown attribute ' . $attribute); |
88 | -} + | } |
89 | -} + | } |
90 | -switch ($attribute) { + | switch ($attribute) { |
91 | -case Doctrine::ATTR_FETCHMODE: + | case Doctrine::ATTR_FETCHMODE: |
92 | -throw new Doctrine_Exception('Deprecated attribute. See http://doctrine.pengus.net/doctrine/manual/new/?chapter=configuration'); + | throw new Doctrine_Exception('Deprecated attribute. See http://doctrine.pengus.net/doctrine/manual/new/?chapter=configuration'); |
93 | -case Doctrine::ATTR_LISTENER: + | case Doctrine::ATTR_LISTENER: |
94 | -$this->setEventListener($value); + | $this->setEventListener($value); |
95 | -break; + | break; |
96 | -case Doctrine::ATTR_COLL_KEY: + | case Doctrine::ATTR_COLL_KEY: |
97 | -if ( ! ($this instanceof Doctrine_Table)) { + | if ( ! ($this instanceof Doctrine_Table)) { |
98 | -throw new Doctrine_Exception("This attribute can only be set at table level."); + | throw new Doctrine_Exception("This attribute can only be set at table level."); |
99 | -} + | } |
100 | -if ($value !== null && ! $this->hasColumn($value)) { + | if ($value !== null && ! $this->hasColumn($value)) { |
101 | -throw new Doctrine_Exception("Couldn't set collection key attribute. No such column '$value'"); + | throw new Doctrine_Exception("Couldn't set collection key attribute. No such column '$value'"); |
102 | -} + | } |
103 | -break; + | break; |
104 | -case Doctrine::ATTR_CACHE: + | case Doctrine::ATTR_CACHE: |
105 | -if ($value !== null) { + | if ($value !== null) { |
106 | -if ( ! ($value instanceof Doctrine_Cache_Interface)) { + | if ( ! ($value instanceof Doctrine_Cache_Interface)) { |
107 | -throw new Doctrine_Exception('Cache driver should implement Doctrine_Cache_Interface'); + | throw new Doctrine_Exception('Cache driver should implement Doctrine_Cache_Interface'); |
108 | -} + | } |
109 | -} + | } |
110 | -break; + | break; |
111 | -case Doctrine::ATTR_VALIDATE: + | case Doctrine::ATTR_VALIDATE: |
112 | -case Doctrine::ATTR_QUERY_LIMIT: + | case Doctrine::ATTR_QUERY_LIMIT: |
113 | -case Doctrine::ATTR_QUOTE_IDENTIFIER: + | case Doctrine::ATTR_QUOTE_IDENTIFIER: |
114 | -case Doctrine::ATTR_PORTABILITY: + | case Doctrine::ATTR_PORTABILITY: |
115 | -case Doctrine::ATTR_DEFAULT_TABLE_TYPE: + | case Doctrine::ATTR_DEFAULT_TABLE_TYPE: |
116 | -case Doctrine::ATTR_EMULATE_DATABASE: + | case Doctrine::ATTR_EMULATE_DATABASE: |
117 | -case Doctrine::ATTR_USE_NATIVE_ENUM: + | case Doctrine::ATTR_USE_NATIVE_ENUM: |
118 | -case Doctrine::ATTR_DEFAULT_SEQUENCE: + | case Doctrine::ATTR_DEFAULT_SEQUENCE: |
119 | -case Doctrine::ATTR_EXPORT: + | case Doctrine::ATTR_EXPORT: |
120 | -case Doctrine::ATTR_DECIMAL_PLACES: + | case Doctrine::ATTR_DECIMAL_PLACES: |
121 | -case Doctrine::ATTR_LOAD_REFERENCES: + | case Doctrine::ATTR_LOAD_REFERENCES: |
122 | -case Doctrine::ATTR_RECORD_LISTENER: + | case Doctrine::ATTR_RECORD_LISTENER: |
123 | -case Doctrine::ATTR_THROW_EXCEPTIONS: + | case Doctrine::ATTR_THROW_EXCEPTIONS: |
124 | -case Doctrine::ATTR_DEFAULT_PARAM_NAMESPACE: + | case Doctrine::ATTR_DEFAULT_PARAM_NAMESPACE: |
125 | -+ | |
126 | -break; + | break; |
127 | -case Doctrine::ATTR_SEQCOL_NAME: + | case Doctrine::ATTR_SEQCOL_NAME: |
128 | -if ( ! is_string($value)) { + | if ( ! is_string($value)) { |
129 | -throw new Doctrine_Exception('Sequence column name attribute only accepts string values'); + | throw new Doctrine_Exception('Sequence column name attribute only accepts string values'); |
130 | -} + | } |
131 | -break; + | break; |
132 | -case Doctrine::ATTR_FIELD_CASE: + | case Doctrine::ATTR_FIELD_CASE: |
133 | -if ($value != 0 && $value != CASE_LOWER && $value != CASE_UPPER) + | if ($value != 0 && $value != CASE_LOWER && $value != CASE_UPPER) |
134 | -throw new Doctrine_Exception('Field case attribute should be either 0, CASE_LOWER or CASE_UPPER constant.'); + | throw new Doctrine_Exception('Field case attribute should be either 0, CASE_LOWER or CASE_UPPER constant.'); |
135 | -break; + | break; |
136 | -case Doctrine::ATTR_SEQNAME_FORMAT: + | case Doctrine::ATTR_SEQNAME_FORMAT: |
137 | -case Doctrine::ATTR_IDXNAME_FORMAT: + | case Doctrine::ATTR_IDXNAME_FORMAT: |
138 | -case Doctrine::ATTR_TBLNAME_FORMAT: + | case Doctrine::ATTR_TBLNAME_FORMAT: |
139 | -if ($this instanceof Doctrine_Table) { + | if ($this instanceof Doctrine_Table) { |
140 | -throw new Doctrine_Exception('Sequence / index name format attributes cannot be set' + | throw new Doctrine_Exception('Sequence / index name format attributes cannot be set' |
141 | -. 'at table level (only at connection or global level).'); + | . 'at table level (only at connection or global level).'); |
142 | -} + | } |
143 | -break; + | break; |
144 | -default: + | default: |
145 | -throw new Doctrine_Exception("Unknown attribute."); + | throw new Doctrine_Exception("Unknown attribute."); |
146 | -} + | } |
147 | -+ | |
148 | -$this->attributes[$attribute] = $value; + | $this->attributes[$attribute] = $value; |
149 | -+ | |
150 | -} + | } |
151 | -+ | |
152 | -public function getParams($namespace = null) + | public function getParams($namespace = null) |
153 | -{ + | { |
154 | -if ($namespace = null) { + | if ($namespace == null) { |
155 | -$namespace = $this->getAttribute(Doctrine::ATTR_DEFAULT_PARAM_NAMESPACE); + | $namespace = $this->getAttribute(Doctrine::ATTR_DEFAULT_PARAM_NAMESPACE); |
156 | -} + | } |
157 | -+ | |
158 | -if ( ! isset($this->_params[$namespace])) { + | if ( ! isset($this->_params[$namespace])) { |
159 | -return null; + | return null; |
160 | -} + | } |
161 | -+ | |
162 | -return $this->_params[$namespace]; + | return $this->_params[$namespace]; |
163 | -} + | } |
164 | -+ | |
165 | -public function getParamNamespaces() + | public function getParamNamespaces() |
166 | -{ + | { |
167 | -return array_keys($this->_params); + | return array_keys($this->_params); |
168 | -} + | } |
169 | -+ | |
170 | -public function setParam($name, $value, $namespace = null) + | public function setParam($name, $value, $namespace = null) |
171 | -{ + | { |
172 | -if ($namespace = null) { + | if ($namespace == null) { |
173 | -$namespace = $this->getAttribute(Doctrine::ATTR_DEFAULT_PARAM_NAMESPACE); + | $namespace = $this->getAttribute(Doctrine::ATTR_DEFAULT_PARAM_NAMESPACE); |
174 | -} + | } |
175 | -+ | |
176 | -$this->_params[$namespace][$name] = $value; + | $this->_params[$namespace][$name] = $value; |
177 | -+ | |
178 | -return $this; + | return $this; |
179 | -} + | } |
180 | -+ | |
181 | -public function getParam($name, $value, $namespace) + | public function getParam($name, $value, $namespace) |
182 | -{ + | { |
183 | -if ($namespace = null) { + | if ($namespace == null) { |
184 | -$namespace = $this->getAttribute(Doctrine::ATTR_DEFAULT_PARAM_NAMESPACE); + | $namespace = $this->getAttribute(Doctrine::ATTR_DEFAULT_PARAM_NAMESPACE); |
185 | -} + | } |
186 | -+ | |
187 | -if ( ! isset($this->_params[$name])) { + | if ( ! isset($this->_params[$name])) { |
188 | -if (isset($this->parent)) { + | if (isset($this->parent)) { |
189 | -return $this->parent->getParam($name); + | return $this->parent->getParam($name); |
190 | -} + | } |
191 | -return null; + | return null; |
192 | -} + | } |
193 | -return $this->_params[$name]; + | return $this->_params[$name]; |
194 | -} + | } |
195 | -/** + | /** |
196 | -* setImpl + | * setImpl |
197 | -* binds given class to given template name + | * binds given class to given template name |
198 | -* + | * |
199 | -* this method is the base of Doctrine dependency injection + | * this method is the base of Doctrine dependency injection |
200 | -* + | * |
201 | -* @param string $template name of the class template + | * @param string $template name of the class template |
202 | -* @param string $class name of the class to be bound + | * @param string $class name of the class to be bound |
203 | -* @return Doctrine_Configurable this object + | * @return Doctrine_Configurable this object |
204 | -*/ + | */ |
205 | -public function setImpl($template, $class) + | public function setImpl($template, $class) |
206 | -{ + | { |
207 | -$this->_impl[$template] = $class; + | $this->_impl[$template] = $class; |
208 | -+ | |
209 | -return $this; + | return $this; |
210 | -} + | } |
211 | -+ | |
212 | -/** + | /** |
213 | -* getImpl + | * getImpl |
214 | -* returns the implementation for given class + | * returns the implementation for given class |
215 | -* + | * |
216 | -* @return string name of the concrete implementation + | * @return string name of the concrete implementation |
217 | -*/ + | */ |
218 | -public function getImpl($template) + | public function getImpl($template) |
219 | -{ + | { |
220 | -if ( ! isset($this->_impl[$template])) { + | if ( ! isset($this->_impl[$template])) { |
221 | -if (isset($this->parent)) { + | if (isset($this->parent)) { |
222 | -return $this->parent->getImpl($template); + | return $this->parent->getImpl($template); |
223 | -} + | } |
224 | -return null; + | return null; |
225 | -} + | } |
226 | -return $this->_impl[$template]; + | return $this->_impl[$template]; |
227 | -} + | } |
228 | -+ | |
229 | -/** + | /** |
230 | -* getCacheDriver + | * getCacheDriver |
231 | -* + | * |
232 | -* @return Doctrine_Cache_Interface + | * @return Doctrine_Cache_Interface |
233 | -*/ + | */ |
234 | -public function getCacheDriver() + | public function getCacheDriver() |
235 | -{ + | { |
236 | -if ( ! isset($this->attributes[Doctrine::ATTR_CACHE])) { + | if ( ! isset($this->attributes[Doctrine::ATTR_CACHE])) { |
237 | -throw new Doctrine_Exception('Cache driver not initialized.'); + | throw new Doctrine_Exception('Cache driver not initialized.'); |
238 | -} + | } |
239 | -+ | |
240 | -return $this->attributes[Doctrine::ATTR_CACHE]; + | return $this->attributes[Doctrine::ATTR_CACHE]; |
241 | -} + | } |
242 | -+ | |
243 | -/** + | /** |
244 | -* @param Doctrine_EventListener $listener + | * @param Doctrine_EventListener $listener |
245 | -* @return void + | * @return void |
246 | -*/ + | */ |
247 | -public function setEventListener($listener) + | public function setEventListener($listener) |
248 | -{ + | { |
249 | -return $this->setListener($listener); + | return $this->setListener($listener); |
250 | -} + | } |
251 | -+ | |
252 | -/** + | /** |
253 | -* addRecordListener + | * addRecordListener |
254 | -* + | * |
255 | -* @param Doctrine_EventListener_Interface|Doctrine_Overloadable $listener + | * @param Doctrine_EventListener_Interface|Doctrine_Overloadable $listener |
256 | -* @return mixed this object + | * @return mixed this object |
257 | -*/ + | */ |
258 | -public function addRecordListener($listener, $name = null) + | public function addRecordListener($listener, $name = null) |
259 | -{ + | { |
260 | -if ( ! isset($this->attributes[Doctrine::ATTR_RECORD_LISTENER]) || + | if ( ! isset($this->attributes[Doctrine::ATTR_RECORD_LISTENER]) || |
261 | -! ($this->attributes[Doctrine::ATTR_RECORD_LISTENER] instanceof Doctrine_Record_Listener_Chain)) { + | ! ($this->attributes[Doctrine::ATTR_RECORD_LISTENER] instanceof Doctrine_Record_Listener_Chain)) { |
262 | -+ | |
263 | -$this->attributes[Doctrine::ATTR_RECORD_LISTENER] = new Doctrine_Record_Listener_Chain(); + | $this->attributes[Doctrine::ATTR_RECORD_LISTENER] = new Doctrine_Record_Listener_Chain(); |
264 | -} + | } |
265 | -$this->attributes[Doctrine::ATTR_RECORD_LISTENER]->add($listener, $name); + | $this->attributes[Doctrine::ATTR_RECORD_LISTENER]->add($listener, $name); |
266 | -+ | |
267 | -return $this; + | return $this; |
268 | -} + | } |
269 | -+ | |
270 | -/** + | /** |
271 | -* getListener + | * getListener |
272 | -* + | * |
273 | -* @return Doctrine_EventListener_Interface|Doctrine_Overloadable + | * @return Doctrine_EventListener_Interface|Doctrine_Overloadable |
274 | -*/ + | */ |
275 | -public function getRecordListener() + | public function getRecordListener() |
276 | -{ + | { |
277 | -if ( ! isset($this->attributes[Doctrine::ATTR_RECORD_LISTENER])) { + | if ( ! isset($this->attributes[Doctrine::ATTR_RECORD_LISTENER])) { |
278 | -if (isset($this->parent)) { + | if (isset($this->parent)) { |
279 | -return $this->parent->getRecordListener(); + | return $this->parent->getRecordListener(); |
280 | -} + | } |
281 | -return null; + | return null; |
282 | -} + | } |
283 | -return $this->attributes[Doctrine::ATTR_RECORD_LISTENER]; + | return $this->attributes[Doctrine::ATTR_RECORD_LISTENER]; |
284 | -} + | } |
285 | -+ | |
286 | -/** + | /** |
287 | -* setListener + | * setListener |
288 | -* + | * |
289 | -* @param Doctrine_EventListener_Interface|Doctrine_Overloadable $listener + | * @param Doctrine_EventListener_Interface|Doctrine_Overloadable $listener |
290 | -* @return Doctrine_Configurable this object + | * @return Doctrine_Configurable this object |
291 | -*/ + | */ |
292 | -public function setRecordListener($listener) + | public function setRecordListener($listener) |
293 | -{ + | { |
294 | -if ( ! ($listener instanceof Doctrine_Record_Listener_Interface) + | if ( ! ($listener instanceof Doctrine_Record_Listener_Interface) |
295 | -&& ! ($listener instanceof Doctrine_Overloadable) + | && ! ($listener instanceof Doctrine_Overloadable) |
296 | -) { + | ) { |
297 | -throw new Doctrine_Exception("Couldn't set eventlistener. Record listeners should implement either Doctrine_Record_Listener_Interface or Doctrine_Overloadable"); + | throw new Doctrine_Exception("Couldn't set eventlistener. Record listeners should implement either Doctrine_Record_Listener_Interface or Doctrine_Overloadable"); |
298 | -} + | } |
299 | -$this->attributes[Doctrine::ATTR_RECORD_LISTENER] = $listener; + | $this->attributes[Doctrine::ATTR_RECORD_LISTENER] = $listener; |
300 | -+ | |
301 | -return $this; + | return $this; |
302 | -} + | } |
303 | -+ | |
304 | -/** + | /** |
305 | -* addListener + | * addListener |
306 | -* + | * |
307 | -* @param Doctrine_EventListener_Interface|Doctrine_Overloadable $listener + | * @param Doctrine_EventListener_Interface|Doctrine_Overloadable $listener |
308 | -* @return mixed this object + | * @return mixed this object |
309 | -*/ + | */ |
310 | -public function addListener($listener, $name = null) + | public function addListener($listener, $name = null) |
311 | -{ + | { |
312 | -if ( ! isset($this->attributes[Doctrine::ATTR_LISTENER]) || + | if ( ! isset($this->attributes[Doctrine::ATTR_LISTENER]) || |
313 | -! ($this->attributes[Doctrine::ATTR_LISTENER] instanceof Doctrine_EventListener_Chain)) { + | ! ($this->attributes[Doctrine::ATTR_LISTENER] instanceof Doctrine_EventListener_Chain)) { |
314 | -+ | |
315 | -$this->attributes[Doctrine::ATTR_LISTENER] = new Doctrine_EventListener_Chain(); + | $this->attributes[Doctrine::ATTR_LISTENER] = new Doctrine_EventListener_Chain(); |
316 | -} + | } |
317 | -$this->attributes[Doctrine::ATTR_LISTENER]->add($listener, $name); + | $this->attributes[Doctrine::ATTR_LISTENER]->add($listener, $name); |
318 | -+ | |
319 | -return $this; + | return $this; |
320 | -} + | } |
321 | -+ | |
322 | -/** + | /** |
323 | -* getListener + | * getListener |
324 | -* + | * |
325 | -* @return Doctrine_EventListener_Interface|Doctrine_Overloadable + | * @return Doctrine_EventListener_Interface|Doctrine_Overloadable |
326 | -*/ + | */ |
327 | -public function getListener() + | public function getListener() |
328 | -{ + | { |
329 | -if ( ! isset($this->attributes[Doctrine::ATTR_LISTENER])) { + | if ( ! isset($this->attributes[Doctrine::ATTR_LISTENER])) { |
330 | -if (isset($this->parent)) { + | if (isset($this->parent)) { |
331 | -return $this->parent->getListener(); + | return $this->parent->getListener(); |
332 | -} + | } |
333 | -return null; + | return null; |
334 | -} + | } |
335 | -return $this->attributes[Doctrine::ATTR_LISTENER]; + | return $this->attributes[Doctrine::ATTR_LISTENER]; |
336 | -} + | } |
337 | -+ | |
338 | -/** + | /** |
339 | -* setListener + | * setListener |
340 | -* + | * |
341 | -* @param Doctrine_EventListener_Interface|Doctrine_Overloadable $listener + | * @param Doctrine_EventListener_Interface|Doctrine_Overloadable $listener |
342 | -* @return Doctrine_Configurable this object + | * @return Doctrine_Configurable this object |
343 | -*/ + | */ |
344 | -public function setListener($listener) + | public function setListener($listener) |
345 | -{ + | { |
346 | -if ( ! ($listener instanceof Doctrine_EventListener_Interface) + | if ( ! ($listener instanceof Doctrine_EventListener_Interface) |
347 | -&& ! ($listener instanceof Doctrine_Overloadable) + | && ! ($listener instanceof Doctrine_Overloadable) |
348 | -) { + | ) { |
349 | -throw new Doctrine_EventListener_Exception("Couldn't set eventlistener. EventListeners should implement either Doctrine_EventListener_Interface or Doctrine_Overloadable"); + | throw new Doctrine_EventListener_Exception("Couldn't set eventlistener. EventListeners should implement either Doctrine_EventListener_Interface or Doctrine_Overloadable"); |
350 | -} + | } |
351 | -$this->attributes[Doctrine::ATTR_LISTENER] = $listener; + | $this->attributes[Doctrine::ATTR_LISTENER] = $listener; |
352 | -+ | |
353 | -return $this; + | return $this; |
354 | -} + | } |
355 | -+ | |
356 | -/** + | /** |
357 | -* returns the value of an attribute + | * returns the value of an attribute |
358 | -* + | * |
359 | -* @param integer $attribute + | * @param integer $attribute |
360 | -* @return mixed + | * @return mixed |
361 | -*/ + | */ |
362 | -public function getAttribute($attribute) + | public function getAttribute($attribute) |
363 | -{ + | { |
364 | -$attribute = (int) $attribute; + | $attribute = (int) $attribute; |
365 | -+ | |
366 | -if ($attribute < 0) { + | if ($attribute < 0) { |
367 | -throw new Doctrine_Exception('Unknown attribute.'); + | throw new Doctrine_Exception('Unknown attribute.'); |
368 | -} + | } |
369 | -+ | |
370 | -if ( ! isset($this->attributes[$attribute])) { + | if ( ! isset($this->attributes[$attribute])) { |
371 | -if (isset($this->parent)) { + | if (isset($this->parent)) { |
372 | -return $this->parent->getAttribute($attribute); + | return $this->parent->getAttribute($attribute); |
373 | -} + | } |
374 | -return null; + | return null; |
375 | -} + | } |
376 | -return $this->attributes[$attribute]; + | return $this->attributes[$attribute]; |
377 | -} + | } |
378 | -+ | |
379 | -/** + | /** |
380 | -* getAttributes + | * getAttributes |
381 | -* returns all attributes as an array + | * returns all attributes as an array |
382 | -* + | * |
383 | -* @return array + | * @return array |
384 | -*/ + | */ |
385 | -public function getAttributes() + | public function getAttributes() |
386 | -{ + | { |
387 | -return $this->attributes; + | return $this->attributes; |
388 | -} + | } |
389 | -+ | |
390 | -/** + | /** |
391 | -* sets a parent for this configurable component + | * sets a parent for this configurable component |
392 | -* the parent must be configurable component itself + | * the parent must be configurable component itself |
393 | -* + | * |
394 | -* @param Doctrine_Configurable $component + | * @param Doctrine_Configurable $component |
395 | -* @return void + | * @return void |
396 | -*/ + | */ |
397 | -public function setParent(Doctrine_Configurable $component) + | public function setParent(Doctrine_Configurable $component) |
398 | -{ + | { |
399 | -$this->parent = $component; + | $this->parent = $component; |
400 | -} + | } |
401 | -+ | |
402 | -/** + | /** |
403 | -* getParent + | * getParent |
404 | -* returns the parent of this component + | * returns the parent of this component |
405 | -* + | * |
406 | -* @return Doctrine_Configurable + | * @return Doctrine_Configurable |
407 | -*/ + | */ |
408 | -public function getParent() + | public function getParent() |
409 | -{ + | { |
410 | -return $this->parent; + | return $this->parent; |
411 | -} + | } |
412 | -} + | } |