CRUDlex\Entity::set PHP Méthode

set() public méthode

Sets a field value pair of this entity.
public set ( string $field, mixed $value )
$field string the field
$value mixed the value
    public function set($field, $value)
    {
        $this->entity[$field] = $value;
    }

Usage Example

Exemple #1
0
 /**
  * Creates a new, empty entity instance having all fields prefilled with
  * null or the defined value in case of fixed fields.
  *
  * @return Entity
  * the newly created entity
  */
 public function createEmpty()
 {
     $entity = new Entity($this->definition);
     $fields = $this->definition->getEditableFieldNames();
     foreach ($fields as $field) {
         $value = null;
         if ($this->definition->getType($field) == 'fixed') {
             $value = $this->definition->getField($field, 'value');
         }
         $entity->set($field, $value);
     }
     $entity->set('id', null);
     return $entity;
 }
All Usage Examples Of CRUDlex\Entity::set