예제 #1
0
 public function build()
 {
     $control = parent::build();
     $instance = ActiveObject::createObject($this->config);
     $instance->run();
     $control['data'] = $instance->getResponse();
     return $control;
 }
예제 #2
0
 function __construct($config = [])
 {
     $this->response = new \stdClass();
     $this->_plugins = new PluginMgr($this);
     $this->_buttons = new ButtonMgr($this);
     $this->name = get_called_class();
     $this->beforeInit();
     parent::__construct($config);
 }
예제 #3
0
 public function load()
 {
     if (isset($this->_value)) {
         $this->config['data'] = $this->getValue();
     }
     $this->component = ActiveObject::createObject($this->config);
     $this->component->run();
     return ['data' => $this->component->getResponse(), 'component' => $this->component->componentName];
 }
예제 #4
0
 public function __construct($config = [])
 {
     $this->response = new \stdClass();
     //$this->response->params = new \stdClass();
     $this->key = ArrayHelper::getValue($config, 'key');
     $this->isNewRecord = !$this->key;
     $this->_config = $config;
     $this->_init();
     parent::__construct($config);
     $this->action = ArrayHelper::getValue($config, 'action', 'load');
 }
예제 #5
0
 protected function createObject($item)
 {
     //create dialog component
     if (empty($item['name']) || is_int($item['name'])) {
         throw new \Exception('Please get the name for step');
     }
     $step = ActiveObject::createObject(array_merge($item, $this->_config));
     if ($step && $step->visible) {
         //todo add  && $step->privilege
         return $step;
     }
 }
예제 #6
0
 public function actionIndex()
 {
     Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
     Yii::$app->response->headers->add('Access-Control-Allow-Origin', '*');
     $dialog = null;
     $response = [];
     try {
         $data = json_decode(urldecode(file_get_contents("php://input")), true);
         unset($data['permissions'], $data['actions'], $data['controls']);
         $dialog = ActiveObject::createObject($data);
         $response = json_encode($dialog->run());
     } catch (ConfirmException $e) {
         $confirm['confirm'] = ArrayHelper::getValue($data, 'confirm', []);
         $confirm['confirm'][$e->id] = ['message' => $e->getMessage(), 'buttons' => $e->buttons];
         $response = json_encode($confirm);
     } catch (ValidationException $e) {
         $response = json_encode(['error' => $e->getMessage(), 'validation' => $e->validation]);
     } catch (HttpException $e) {
         throw $e;
     }
     Yii::$app->response->format = 'html';
     return $response;
 }
예제 #7
0
 public function load()
 {
     $instance = ActiveObject::createObject($this->config);
     $instance->run();
     return ['data' => $instance->getResponse()];
 }
예제 #8
0
 protected function redirect($config)
 {
     if (empty($config['action'])) {
         $config['action'] = 'load';
     }
     if (empty($config['key'])) {
         $config['key'] = $this->key;
     }
     if (empty($config['filter'])) {
         $config['filter'] = $this->filter;
     }
     $dialog = ActiveObject::createObject($config);
     $this->response = $dialog->run();
     if (!$this->response->params) {
         $this->response->params = new \stdClass();
     }
     $this->response->params->class = $config['class'];
 }