loadController() public static méthode

public static loadController ( $controller, $prefix = 'Scalr_UI_Controller', $checkPermissions = false ) : Scalr_UI_Controller
Résultat Scalr_UI_Controller
Exemple #1
0
 public function checkLifeCycle($widgets)
 {
     $result = array();
     foreach ($widgets as $id => $object) {
         $name = str_replace('dashboard.', '', $object['name']);
         try {
             $widget = Scalr_UI_Controller::loadController($name, 'Scalr_UI_Controller_Dashboard_Widget');
         } catch (Exception $e) {
             continue;
         }
         $result[$id] = $widget->getContent($object['params']);
     }
     return $result;
 }
Exemple #2
0
 /**
  * Get internal request to the controller's action ignoring checking aliases
  *
  * @param   string   $uri
  * @param   array    $parameters
  * @return  mixed    Returns raw response as it is returned by action
  */
 protected function internalRequest($uri, array $parameters = array())
 {
     $aUri = parse_url($uri);
     call_user_func_array(array($this, 'getRequest'), array_merge(array(Scalr_UI_Request::REQUEST_TYPE_UI, null), func_get_args()));
     $path = explode('/', trim($aUri['path'], '/'));
     $method = array_pop($path) . 'Action';
     $subController = ucfirst(array_pop($path));
     $controller = 'Scalr_UI_Controller' . (count($path) ? '_' . join('_', array_map('ucfirst', $path)) : '');
     $c = \Scalr_UI_Controller::loadController($subController, $controller, true);
     $c->{$method}();
     // TODO: use $c->callActionMethod($method);
     $content = Scalr_UI_Response::getInstance()->getResponse();
     $arr = @json_decode($content, true);
     return $arr === null ? $content : $arr;
 }
Exemple #3
0
 public function checkLifeCycle($widgets)
 {
     $result = array();
     foreach ($widgets as $id => $object) {
         $name = str_replace('dashboard.', '', $object['name']);
         try {
             $widget = Scalr_UI_Controller::loadController($name, 'Scalr_UI_Controller_Dashboard_Widget');
         } catch (Exception $e) {
             continue;
         }
         try {
             $result[$id]['widgetContent'] = $widget->getContent($object['params']);
         } catch (ADODB_Exception $e) {
             \Scalr::logException($e);
             $result[$id]['widgetError'] = 'Database error';
         } catch (Exception $e) {
             $result[$id]['widgetError'] = $e->getMessage();
         }
     }
     return $result;
 }
Exemple #4
0
 /**
  * @param int $userId
  * @param int $envId
  * @param JsonData $uiStorage
  * @param JsonData $updateDashboard
  */
 public function xPerpetuumMobileAction($userId, $envId, JsonData $uiStorage, JsonData $updateDashboard)
 {
     $result = array();
     if ($this->user) {
         if ($updateDashboard) {
             $result['updateDashboard'] = Scalr_UI_Controller::loadController('dashboard')->checkLifeCycle($updateDashboard);
         }
         if (!Scalr_Session::getInstance()->isVirtual() && $uiStorage) {
             $this->user->setSetting(Scalr_Account_User::SETTING_UI_STORAGE_TIME, $uiStorage['time']);
             $this->user->setVar(Scalr_Account_User::VAR_UI_STORAGE, $uiStorage['dump']);
         }
     }
     $equal = $this->user && $this->user->getId() == $userId && ($this->getEnvironment() ? $this->getEnvironmentId() : 0) == $envId;
     $result['equal'] = $equal;
     $result['isAuthenticated'] = $this->user ? true : false;
     $this->response->data($result);
 }
Exemple #5
0
 public function xPerpetuumMobileAction()
 {
     $result = array();
     if ($this->user) {
         if ($this->getParam('updateDashboard')) {
             $result['updateDashboard'] = Scalr_UI_Controller::loadController('dashboard')->checkLifeCycle($this->getParam('updateDashboard'));
         }
         //if (!Scalr_Session::getInstance()->isVirtual() && $this->getParam('uiStorage'))
         //    $this->user->setVar(Scalr_Account_User::VAR_UI_STORAGE, $this->getParam('uiStorage'));
     }
     $equal = $this->user && $this->user->getId() == $this->getParam('userId') && ($this->getEnvironment() ? $this->getEnvironmentId() : 0) == $this->getParam('envId');
     $result['equal'] = $equal;
     $result['isAuthenticated'] = $this->user ? true : false;
     $this->response->data($result);
 }
Exemple #6
0
 public function xPerpetuumMobileAction()
 {
     $result = array();
     if ($this->user) {
         if ($this->getParam('updateDashboard')) {
             $result['updateDashboard'] = Scalr_UI_Controller::loadController('dashboard')->checkLifeCycle($this->getParam('updateDashboard'));
         }
     }
     $equal = $this->user && $this->user->getId() == $this->getParam('userId') && ($this->getEnvironment() ? $this->getEnvironmentId() : 0) == $this->getParam('envId');
     $result['equal'] = $equal;
     $result['isAuthenticated'] = $this->user ? true : false;
     $this->response->data($result);
 }