Ejemplo n.º 1
0
 /**
  * @param CM_FormAction_Abstract $action
  * @throws CM_Exception_Invalid
  */
 protected function registerAction(CM_FormAction_Abstract $action)
 {
     $actionName = $action->getName();
     if (isset($this->_actions[$actionName])) {
         throw new CM_Exception_Invalid('Form action is already registered.', null, ['actionName' => $actionName]);
     }
     $this->_actions[$actionName] = $action;
 }
Ejemplo n.º 2
0
 /**
  * @param CM_FormAction_Abstract        $action
  * @param array|null                    $data
  * @param CM_Frontend_ViewResponse|null $scopeView
  * @param CM_Frontend_ViewResponse|null $scopeComponent
  * @throws CM_Exception_Invalid
  * @return CM_Http_Request_Post|\Mocka\AbstractClassTrait
  */
 public function createRequestFormAction(CM_FormAction_Abstract $action, array $data = null, CM_Frontend_ViewResponse $scopeView = null, CM_Frontend_ViewResponse $scopeComponent = null)
 {
     $actionName = $action->getName();
     $form = $action->getForm();
     if (null === $scopeView) {
         $scopeView = new CM_Frontend_ViewResponse($form);
     }
     if ($scopeView->getView() !== $form) {
         throw new CM_Exception_Invalid('Action\'s form and ViewResponse\'s view must match');
     }
     if (null === $scopeComponent) {
         $component = $this->mockClass('CM_Component_Abstract')->newInstance();
         $scopeComponent = new CM_Frontend_ViewResponse($component);
     }
     $query = array('data' => (array) $data, 'actionName' => $actionName);
     return $this->createRequest('/form/null', $query, null, $scopeView, $scopeComponent);
 }
Ejemplo n.º 3
0
 /**
  * @param CM_FormAction_Abstract        $action
  * @param array|null                    $data
  * @param CM_Frontend_ViewResponse|null $scopeView
  * @param CM_Frontend_ViewResponse|null $scopeComponent
  * @param CM_Site_Abstract|null         $site
  * @return CM_Http_Request_Post|\Mocka\AbstractClassTrait
  * @throws CM_Exception_Invalid
  */
 public function createRequestFormAction(CM_FormAction_Abstract $action, array $data = null, CM_Frontend_ViewResponse $scopeView = null, CM_Frontend_ViewResponse $scopeComponent = null, CM_Site_Abstract $site = null)
 {
     $actionName = $action->getName();
     $form = $action->getForm();
     if (null === $scopeView) {
         $scopeView = new CM_Frontend_ViewResponse($form);
     }
     if ($scopeView->getView() !== $form) {
         throw new CM_Exception_Invalid('Action\'s form and ViewResponse\'s view must match');
     }
     if (null === $scopeComponent) {
         /** @var CM_Component_Abstract $component */
         $component = $this->mockClass('CM_Component_Abstract')->newInstance();
         $scopeComponent = new CM_Frontend_ViewResponse($component);
     }
     $query = array('data' => (array) $data, 'actionName' => $actionName);
     if (null === $site) {
         $site = CM_Site_Abstract::factory();
     }
     $headers = ['host' => $site->getHost()];
     return $this->createRequest($site->getUrl() . '/form', $query, $headers, $scopeView, $scopeComponent);
 }