Exemplo n.º 1
0
 public function testConstructorInjectionOfProperties()
 {
     $data = array('title' => 'My Title', 'content' => 'My Content', 'published_date' => '2009-08-17T17:30:00Z', 'author' => new ZFExt_Model_Author());
     $entry = new ZFExt_Model_Entry($data);
     $expected = $data;
     $expected['id'] = null;
     $this->assertEquals($expected, $entry->toArray());
 }
Exemplo n.º 2
0
 public function save(ZFExt_Model_Entry $entry)
 {
     $data = $entry->toArray();
     $data['author_id'] = $entry->author->id;
     unset($data['author']);
     //        Zend_Debug::dump($data);
     if (!$entry->id) {
         $entry->id = $this->_getGateway()->insert($data);
         $this->_setIdentity($entry->id, $entry);
     } else {
         $where = $this->_getGateway()->getAdapter()->quoteInto('id = ?', $entry->id);
         $this->_getGateway()->update($data, $where);
     }
 }