A generic MVC controller implementation
Beispiel #1
0
 public function __construct(Container $container, array $config)
 {
     if (!is_array($config)) {
         $config = [];
     }
     $config['modelName'] = 'Statistics';
     parent::__construct($container, $config);
 }
Beispiel #2
0
 /**
  * A mocked object will have a random name, that won't match the regex expression in the parent.
  * To prevent exceptions, we have to manually set the name
  *
  * @return string
  */
 public function getName()
 {
     if (isset($this->mockedMethods['getName'])) {
         $func = $this->mockedMethods['getName'];
         return call_user_func_array($func, array());
     }
     return parent::getName();
 }
Beispiel #3
0
 public function __construct(Container $container, array $config)
 {
     parent::__construct($container, $config);
     $this->setPredefinedTaskList(['wizard', 'checkUrl', 'applyConnection', 'initialiseUpload', 'upload', 'reset']);
 }
 public function __construct(Container $container, array $config)
 {
     parent::__construct($container, $config);
     $this->setPredefinedTaskList(['main', 'ajax']);
 }
Beispiel #5
0
 public function __construct(Container $container, array $config = array())
 {
     parent::__construct($container, $config);
     $this->predefinedTaskList = ['force'];
 }
Beispiel #6
0
 public function execute($task)
 {
     $task = 'main';
     $this->layout = 'latest';
     return parent::execute($task);
 }
Beispiel #7
0
 /**
  * Returns a named Model object. Makes sure that the Model is a database-aware model, throwing an exception
  * otherwise, when $name is null.
  *
  * @param   string $name     The Model name. If null we'll use the modelName
  *                           variable or, if it's empty, the same name as
  *                           the Controller
  * @param   array  $config   Configuration parameters to the Model. If skipped
  *                           we will use $this->config
  *
  * @return  DataModel  The instance of the Model known to this Controller
  *
  * @throws  NotADataModel  When the model type doesn't match our expectations
  */
 public function getModel($name = null, $config = array())
 {
     $model = parent::getModel($name, $config);
     if (is_null($name) && !$model instanceof DataModel) {
         throw new NotADataModel('Model ' . get_class($model) . ' is not a database-aware Model');
     }
     return $model;
 }
Beispiel #8
0
 public function __construct(Container $container, array $config = array())
 {
     parent::__construct($container, $config);
     $this->setPredefinedTaskList(['main', 'SwitchProfile', 'UpdateInfo', 'applydlid', 'resetSecretWord', 'reloadUpdateInformation']);
 }
Beispiel #9
0
 /**
  * Determines the task from the layout and view format
  *
  * @param   string  $task  The task to execute
  *
  * @return  void
  */
 public function execute($task)
 {
     $document = JFactory::getDocument();
     $viewType = $document->getType();
     $task = $this->input->getCmd('task', '');
     $layout = $this->input->getCmd('layout', '');
     $id = $this->input->getInt('id', null);
     // Check for menu items bearing layout instead of task
     if (empty($task) || $task == 'main' && !empty($layout)) {
         $task = $layout;
     }
     // Check for default task
     if (empty($task) || $task == 'read' || $task == 'add') {
         if ($viewType == 'xml') {
             $task = 'all';
         } elseif ($viewType == 'ini' && empty($id)) {
             throw new \RuntimeException(\JText::_('ARS_ERR_NOUPDATESOURCE'), 500);
         } elseif ($viewType == 'ini') {
             $task = 'ini';
         } elseif ($viewType == 'raw' && empty($id)) {
             throw new \RuntimeException(\JText::_('ARS_ERR_NOUPDATESOURCE'), 500);
         } elseif ($viewType == 'raw') {
             $task = 'download';
         } else {
             $task = 'ini';
         }
     }
     switch ($task) {
         case 'ini':
             $viewType = 'ini';
             break;
         case 'download':
             $viewType = 'raw';
             break;
         default:
             $viewType = 'xml';
             break;
     }
     switch ($viewType) {
         default:
         case 'xml':
             switch ($task) {
                 default:
                 case 'all':
                     $task = 'all';
                     break;
                 case 'category':
                     $task = 'category';
                     break;
                 case 'stream':
                     $task = 'stream';
                     break;
             }
             break;
         case 'ini':
             $task = 'ini';
             break;
         case 'raw':
             $task = 'download';
             break;
     }
     parent::execute($task);
 }
Beispiel #10
0
 public function __construct(Container $container, array $config = array())
 {
     parent::__construct($container, $config);
     $this->predefinedTaskList = ['main', 'category', 'upload', 'delete', 'newFolder'];
 }
Beispiel #11
0
 public function __construct(Container $container, array $config = array())
 {
     parent::__construct($container, $config);
     $this->predefinedTaskList = ['main', 'updategeoip', 'updateinfo'];
 }