Example #1
0
 /**
  * Create a field object for the many-to-many relationship matching the
  * supplied name.
  *
  * @param string $name
  * @return \Dewdrop\Db\ManyToMany\Field
  */
 public function instantiate($name)
 {
     $rel = $this->table->getManyToManyRelationship($name);
     $field = new Field($this->table, $name, $rel->getFieldMetadata());
     $field->setManyToManyRelationship($rel);
     return $field;
 }
Example #2
0
 /**
  * Get the value of the specified column.
  *
  * @param string $name
  * @return mixed
  * @throws Exception
  */
 public function get($name)
 {
     if (!in_array($name, $this->columns)) {
         throw new Exception("Getting value of invalid  column \"{$name}\"");
     }
     if ($this->table->hasManyToManyRelationship($name) && !in_array($name, $this->virtualFieldsInitialized) && !isset($this->data[$name])) {
         $relationship = $this->table->getManyToManyRelationship($name);
         $this->virtualFieldsInitialized[] = $name;
         $this->data[$name] = $relationship->loadInitialValue($this);
     }
     if ($this->table->hasEav() && $this->table->getEav()->hasAttribute($name) && !in_array($name, $this->virtualFieldsInitialized)) {
         $this->virtualFieldsInitialized[] = $name;
         $this->data[$name] = $this->table->getEav()->loadInitialValue($this, $name);
     }
     return isset($this->data[$name]) ? $this->data[$name] : null;
 }