]> dev.renevier.net Git - syj.git/blob - application/controllers/helpers/SyjPostData.php
update copyright headers
[syj.git] / application / controllers / helpers / SyjPostData.php
1 <?php
2 /*  This file is part of Syj, Copyright (c) 2010-2011 Arnaud Renevier,
3     and is published under the AGPL license. */
4
5 class Syj_Controller_Action_Helper_SyjPostData extends Zend_Controller_Action_Helper_Abstract
6 {
7
8     public function getPostData($form) {
9         if (is_string($form) and class_exists($form)) {
10             $form = new $form;
11         }
12         if (!$form instanceof Zend_Form) {
13             throw new Zend_Exception();
14         }
15
16         if (!$this->getRequest()->isPost()) {
17             throw new Syj_Exception_Request();
18         }
19         $data = $this->getRequest()->getPost();
20
21         if ($form instanceof Syj_Processor_Interface) {
22             $form->process($data);
23         }
24
25         if (!$form->isValid($data)) {
26             throw new Syj_Exception_Request();
27         }
28
29         return $data;
30     }
31
32 }