Example #1
0
 /**
  * @param  string $name
  * @throws Table\TableException
  * @return \Dive\Collection\RecordCollection|Record|null|mixed|string
  */
 public function get($name)
 {
     if ($this->_table->hasField($name)) {
         if (array_key_exists($name, $this->_data)) {
             return $this->_data[$name];
         }
         return $this->_table->getFieldDefaultValue($name);
     }
     if ($this->_table->hasRelation($name)) {
         return $this->_table->getReferenceFor($this, $name);
     }
     $recordPropertyEvent = new RecordPropertyEvent($this, $name);
     $this->getEventDispatcher()->dispatch(self::EVENT_NON_EXISTING_PROPERTY_GET, $recordPropertyEvent);
     if ($recordPropertyEvent->isPropagationStopped()) {
         return $recordPropertyEvent->getValue();
     }
     throw $this->_table->getFieldOrRelationNotExistsException($name);
 }