]> dev.renevier.net Git - syj.git/blob - application/controllers/helpers/SyjPostData.php
3f18222545f7e2e0cfdd710bf40310ea9b8fd52f
[syj.git] / application / controllers / helpers / SyjPostData.php
1 <?php
2 /*  This file is part of Syj, Copyright (c) 2010 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         if (!$form->isValid($data)) {
21             throw new Syj_Exception_Request();
22         }
23
24         return $data;
25     }
26
27 }