Example #1
0
 public function __construct($action = null, $format = null)
 {
     $this->setModule(strtolower(str_replace('Controller', '', get_class($this))));
     if (!isset($action) || !isset($format)) {
         $defaultParts = Config::get('defaultRouteParts');
     }
     $this->setAction(isset($action) ? $action : $defaultParts['action']);
     $this->setFormat(isset($format) ? $format : $defaultParts['format']);
     $route = new Route($this->getAction());
     $route->setFormat($this->getFormat());
     $this->_route = $route;
 }
Example #2
0
 public function process()
 {
     switch ($this->_attributeParse()) {
         case 'form':
             $controller = Controller::fromRoute(new Route('_core/component:form'));
             $controller->setFormAction($this->attributes['route']);
             $controller->setFormId(issetor($this->attributes['id'], spl_object_hash($this)));
             $controller->setExtraClass(issetor($this->attributes['class'], ''));
             $controller->setInnerXml($this->innerXml);
             return $controller->invoke();
             break;
         case 'ajax':
             $controller = Controller::fromRoute(new Route('_core/component:formAjax'));
             $formAction = new Route($this->attributes['route']);
             $formAction->setFormat(issetor($this->attributes['format'], 'json'));
             $controller->setFormAction($formAction->__toString());
             $controller->setFormFormat(issetor($this->attributes['format'], 'json'));
             $controller->setFormId(issetor($this->attributes['id'], spl_object_hash($this)));
             $controller->setExtraClass(issetor($this->attributes['class'], ''));
             $controller->setInnerXml($this->innerXml);
             return $controller->invoke();
             break;
         case 'upload':
             $controller = Controller::fromRoute(new Route('_core/component:formUpload'));
             if (!isset($this->attributes['options']) || !isset($this->attributes['options']['saveDir']) || !isset($this->attributes['options']['extensions'])) {
                 // TODO:
                 throw new Exception('Options saveDir and extensions must be set for AC.Form.Upload');
             }
             $controller->setName($this->attributes['name']);
             $controller->setOptions($this->attributes['options']);
             $controller->setInputId(issetor($this->attributes['id'], spl_object_hash($this)));
             $controller->setExtraClass(issetor($this->attributes['class'], ''));
             return $controller->invoke();
             break;
         case 'embed':
             $controller = Controller::fromRoute(new Route('form/view.html'));
             $controller->setId($this->attributes['id']);
             return $controller->invoke();
             break;
     }
     // TODO:
     throw new Exception();
 }