Example #1
0
 /**
  * @param  string                                                     $name
  * @param  \Dive\Collection\RecordCollection|Record|null|mixed|string $value
  * @throws Table\TableException
  */
 public function set($name, $value)
 {
     if ($this->_table->hasField($name)) {
         $this->setFieldValue($name, $value);
         return;
     }
     if ($this->_table->hasRelation($name)) {
         $this->_table->setReferenceFor($this, $name, $value);
         return;
     }
     $recordPropertyEvent = new RecordPropertyEvent($this, $name, $value);
     $this->getEventDispatcher()->dispatch(self::EVENT_NON_EXISTING_PROPERTY_SET, $recordPropertyEvent);
     if ($recordPropertyEvent->isPropagationStopped()) {
         return;
     }
     throw $this->_table->getFieldOrRelationNotExistsException($name);
 }