public function toObject(array $import) { $fields = array('publication_id' => null, 'publication_cat_id' => null, 'language' => null, 'name' => null, 'description' => null, 'content' => null, 'publication_date' => null); foreach ($import as $key => $value) { if (array_key_exists($key, $fields)) { $fields[$key] = $value; } } $category = new SxCms_Publication_Category(); $category->setId($fields['publication_cat_id']); $publication = new SxCms_Publication(); $publication->setId($fields['publication_id'])->setLanguage($fields['language'])->setName($fields['name'])->setDescription($fields['description'])->setContent($fields['content'])->setPublicationDate($fields['publication_date'])->setCategory($category); return $publication; }
public function getAll() { $db = Zend_Registry::get('db'); $select = $db->select()->from('PublicationCat', array('*'))->where('language = ?', $_SESSION['System']['lng']); $stmt = $db->query($select); $result = $stmt->fetchAll(); $publications = array(); foreach ($result as $pub) { $publication = new SxCms_Publication_Category(); $publication->setId($pub['publication_cat_id'])->setLanguage($pub['language'])->setName($pub['name'])->setDescription($pub['description']); $publications[$publication->getId()] = $publication; } return $publications; }