Esempio n. 1
0
 public function testGetArrayCopyReturnsAnArrayWithPropertyValues()
 {
     $album = new Page();
     $data = array('article' => 'some artist', 'id' => 123, 'title' => 'some title');
     $album->exchangeArray($data);
     $copyArray = $album->getArrayCopy();
     $this->assertSame($data['article'], $copyArray['article'], '"artist" was not set correctly');
     $this->assertSame($data['id'], $copyArray['id'], '"id" was not set correctly');
     $this->assertSame($data['title'], $copyArray['title'], '"title" was not set correctly');
 }
Esempio n. 2
0
 public function addAction()
 {
     $form = new PageForm();
     //Создаем форму
     $request = $this->getRequest();
     //Обращение к запросу в форме (получение запроса)
     if ($request->isPost()) {
         $page = new Model\Page();
         $form->setInputFilter($page->getInputFilter());
         //Привязываем фильтр
         //Заполняем форму значениями
         $form->setData($request->getPost());
         //Используем фильтр
         if ($form->isValid()) {
             $page->exchangeArray($form->getData());
             //Формируем массив
             $this->getPageTable()->savePage($page);
             //Возвращаем и сохраняем
             return $this->redirect()->toRoute('page');
         }
     }
     return new ViewModel(['form' => $form]);
 }
 /**
  *
  * @return \Zend\View\Model\ViewModel
  */
 public function addAction()
 {
     $form = new PageForm();
     $request = $this->getRequest();
     if ($request->isPost()) {
         $page = new Page();
         $form->setInputFilter($page->getInputFilter());
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $page->exchangeArray($form->getData());
             $this->getPageTable()->savePage($page);
             $this->redirect()->toRoute("page");
         }
     }
     return new ViewModel(array("form" => $form));
 }