Ejemplo n.º 1
0
    /**
     * Load all available material types.
     *
     * @return \self
     */
    public static function loadList()
    {
        $sql = '
			SELECT `materialTypeId`
			FROM materialTypes
			WHERE !deleted
			ORDER BY `name`
		';
        $materialTypeIds = query($sql, true);
        $obj = new self();
        if (empty($materialTypeIds)) {
            return $obj;
        }
        $list = array();
        foreach ($materialTypeIds as $materialType) {
            $list[$materialType['materialTypeId']] = \Model\MaterialType::loadById($materialType['materialTypeId']);
        }
        $obj->setList($list);
        return $obj;
    }
Ejemplo n.º 2
0
 /**
  * Fill the objects properties with the given data and cast them if possible to the best
  * matching type. Only existing properties are filled.
  *
  * @param type $data
  *
  * @return void
  */
 public function fill($data)
 {
     foreach ($data as $key => $value) {
         if ($key === 'materialTypeId') {
             $this->materialType = \Model\MaterialType::loadById($value);
         } elseif (property_exists($this, $key)) {
             $this->{$key} = $this->castToType($value);
         }
     }
 }