public function addField(Field $field)
    {
        $tmp               = $this->fields->getValue($this->entity);
        $tmp[$field->name] = $field;
        $this->fields->setValue($this->entity, $tmp);

        if ($field->role == 'id') {
            $key = new \ReflectionProperty(Entity::class, 'key');
            $key->setAccessible(true);
            $key->setValue($this->entity, $field->name);
        }
    }
public function addField(Field $field)
    {
        $tmp               = $this->fields->getValue($this->entity);
        $tmp[$field->name] = $field;
        $this->fields->setValue($this->entity, $tmp);

        if ($field->role == 'id') {
            $key = new \ReflectionProperty(Entity::class, 'key');
            $key->setAccessible(true);
            $key->setValue($this->entity, $field->name);
        }
    }
public function addField ( Field $ field ) { $ tmp = $ this -> fields -> getValue ( $ this -> entity ) ; $ tmp [ $ field -> name ] = $ field ; $ this -> fields -> setValue ( $ this -> entity , $ tmp ) ; if ( $ field -> role == 'id' ) { $ key = new \ ReflectionProperty ( Entity :: class , 'key' ) ; $ key -> setAccessible ( true ) ; $ key -> setValue ( $ this -> entity , $ field -> name ) ; } }
Add a field to the entity

@param   Field $field The field to add

@return  void
Add a field to the entity