Exemplo n.º 1
0
 function get($name, $default = LIMB_UNDEFINED)
 {
     if (!$name) {
         throw new lmbInvalidArgumentException('Option name not given');
     }
     try {
         return parent::get($name, $default);
     } catch (lmbNoSuchPropertyException $e) {
         throw new lmbNoSuchPropertyException('Option ' . $name . ' not found', array('config' => $this->_file));
     }
 }
Exemplo n.º 2
0
 /**
  *  Generic magic getter for any attribute
  *  @param string property name
  *  @return mixed
  */
 function get($property, $default = LIMB_UNDEFINED)
 {
     if (!$this->isNew() && $this->_izLazyAttribute($property) && !parent::has($property)) {
         $this->_loadLazyAttribute($property);
     }
     if ($this->_hasAggregatedObjectRelation($property)) {
         if ($aggregated_object = $this->_getAggregatedObject($property)) {
             return $aggregated_object;
         }
         return LIMB_UNDEFINED !== $default ? $default : $aggregated_object;
     }
     try {
         return parent::get($property);
     } catch (lmbNoSuchPropertyException $e) {
     }
     if (LIMB_UNDEFINED !== $default) {
         return $default;
     }
     if (in_array($property, $this->_db_table_fields)) {
         return null;
     }
     if ($this->isNew() && $this->_hasSingleObjectRelation($property)) {
         return null;
     }
     if (!$this->isNew() && $this->_hasBelongsToRelation($property)) {
         $object = $this->_loadBelongsToObject($property);
         $this->_setRaw($property, $object);
         return $object;
     }
     if (!$this->isNew() && $this->_hasManyBelongsToRelation($property)) {
         $object = $this->_loadManyBelongsToObject($property);
         $this->_setRaw($property, $object);
         return $object;
     }
     if (!$this->isNew() && $this->_hasOneToOneRelation($property)) {
         $object = $this->_loadOneToOneObject($property);
         $this->_setRaw($property, $object);
         return $object;
     }
     if ($this->_hasCollectionRelation($property)) {
         $collection = $this->createRelationCollection($property);
         $this->_setRaw($property, $collection);
         return $collection;
     }
     throw $e;
 }
Exemplo n.º 3
0
 function testImplementsArrayAccessInterface()
 {
     $o = new lmbObject();
     $o->set('foo', 'Bar');
     $this->assertEqual($o['foo'], 'Bar');
     $o['foo'] = 'Zoo';
     $this->assertEqual($o->get('foo'), 'Zoo');
     unset($o['foo']);
     $this->assertFalse($o->has('foo'));
     $o->set('foo', 'Bar');
     $this->assertTrue(isset($o['foo']));
     $this->assertFalse(isset($o['bar']));
 }
Exemplo n.º 4
0
 /**
  * Gets variable from toolkit
  * Checks if appropriate getter method in tools exists to delegate to
  * @return mixed
  */
 function get($var, $default = LIMB_UNDEFINED)
 {
     if ($method = $this->_mapPropertyToGetMethod($var)) {
         return $this->{$method}();
     } else {
         return parent::get($var, $default);
     }
 }