FOF30\Controller\DataController::onAfterExecute PHP Method

onAfterExecute() protected method

Deal with JSON format: no redirects needed
protected onAfterExecute ( string $task ) : boolean
$task string The task being executed
return boolean True if everything went well
    protected function onAfterExecute($task)
    {
        // JSON shouldn't have redirects
        if ($this->hasRedirect() && $this->input->getCmd('format', 'html') == 'json') {
            // Error: deal with it in REST api way
            if ($this->messageType == 'error') {
                $response = new \JResponseJson($this->message, $this->message, true);
                echo $response;
                $this->redirect = false;
                $this->container->platform->setHeader('Status', 500);
                return;
            } else {
                // Not an error, avoid redirect and display the record(s)
                $this->redirect = false;
                return $this->display();
            }
        }
        return true;
    }