Changeset 4938 for trunk/lib/Doctrine
- Timestamp:
- 09/12/08 13:14:14 (4 months ago)
- Files:
-
- 1 modified
-
trunk/lib/Doctrine/Common/Configuration.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/Doctrine/Common/Configuration.php
r4937 r4938 29 29 * 30 30 * INTERNAL: When adding a new configuration option just write a getter/setter 31 * combinationand add the option to the _attributes array with a proper default value.31 * pair and add the option to the _attributes array with a proper default value. 32 32 * 33 33 * @author Roman Borschel <roman@code-factory.org> … … 36 36 class Doctrine_Common_Configuration 37 37 { 38 private $_nullObject;39 40 38 /** 41 39 * The attributes that are contained in the configuration. 42 * Values are default values. PHP null is replaced by a reference to the Null 43 * object on instantiation in order to use isset() instead of array_key_exists(). 40 * Values are default values. 44 41 * 45 42 * @var array … … 59 56 */ 60 57 public function __construct() 61 { 62 $this->_nullObject = new stdClass(); 63 $this->_initAttributes(); 64 } 65 66 /** 67 * Initializes the attributes. 68 * Changes null default values to references to the Null object to allow 69 * fast isset() checks instead of array_key_exists(). 70 * 71 * @return void 72 */ 73 private function _initAttributes() 74 { 75 foreach ($this->_attributes as $key => $value) { 76 if ($value === null) { 77 $this->_attributes[$key] = $this->_nullObject; 78 } 79 } 80 } 81 82 /** 83 * Checks whether the configuration contains/supports an attribute. 84 * 85 * @param string $name 86 * @return boolean 87 */ 88 public function has($name) 89 { 90 return isset($this->_attributes[$name]); 91 } 58 {} 92 59 93 60 public function getQuoteIdentifiers()