execute() public method

If $task == 'default' we will determine the CRUD task to use based on the view name and HTTP verb in the request, overriding the routing.
public execute ( string $task ) : null | boolean
$task string The task to execute, e.g. "browse"
return null | boolean False on execution failure
Esempio n. 1
0
 public function execute($task)
 {
     // If we're using the JSON API we need a manager
     $format = $this->input->getCmd('format', 'html');
     if ($format == 'json' && !($this->checkACL('core.manage') || $this->checkACL('core.admin'))) {
         throw new \RuntimeException(\JText::_('JLIB_APPLICATION_ERROR_ACCESS_FORBIDDEN'), 403);
     }
     // For the HTML view we only allow browse and download
     if ($format != 'json') {
         if (!in_array($task, ['browse', 'download'])) {
             $task = 'browse';
         }
     }
     return parent::execute($task);
 }