/** * prepare data to be returned from query * @param array * @return Person_Model_Person */ protected function _prepareReturnData($data, $returnArray = true) { if (is_array($data)) { if (!isset($data[0])) { $data = array(0 => $data); } $col = array(); foreach ($data as $row) { if ($row) { $o = new Persons_Model_Person($row); $md = new Media_Domain_Image(); $media = $md->getByRelation('person_media', $row['id']); $o->setMedia($media); $col[] = $o; } } if ($returnArray) { return $col; } else { return $col[0]; } } else { return null; } }
/** * @return Media_Model_Image */ public function getMedia() { if (is_null($this->media)) { $md = new Media_Domain_Image(); $this->media = $md->getByRelation('person', $this->id); if (is_null($this->media)) { $this->media = new Media_Model_Image(); } } return $this->media; }