public function hydrate(array $data = array()) { foreach ($data as $value) { $intervention = new Intervention(); $intervention->hydrate($value); $this[] = $intervention; } }
public function add(Intervention $intervention) { $q = $this->_db->prepare('INSERT INTO intervention SET nom = :nom, prix= :prix'); $q->bindValue(':nom', $intervention->nom(), PDO::PARAM_STR); $q->bindValue(':prix', $intervention->prix(), PDO::PARAM_INT); $q->execute(); $intervention->hydrate(['id' => $this->_db->lastInsertId(), 'nom' => $intervention->nom(), 'prix' => $intervention->prix()]); return self::ACTION_REUSSIE; }
public function hydrate(array $data = array()) { parent::hydrate($data); if (isset($data['intervention'])) { $this->intervention = new Intervention(); if (!is_array($data['intervention'])) { throw new \Bixev\Rest\Exception\Rest\E400BadRequest('Invalid parameter "intervention"'); } $this->intervention->hydrate($data['intervention']); } if (isset($data['custom_fields'])) { $this->custom_fields = new InterventionReportCustomFields(); if (!is_array($data['custom_fields'])) { throw new \Bixev\Rest\Exception\Rest\E400BadRequest('Invalid parameter "custom_fields"'); } $this->custom_fields->hydrate($data['custom_fields']); } }