Hi,
I often need to make REST API with Phalcon. So the views are not needed to me. But if I set in controller:
$this->response->setJsonContent($responseData);
I get empty response. So always I need to do one more step:
return $this->response;
Maybe there is some easy fix/hack to not try to render views if json response are set?
Real code example which I want to simplify:
<?php
use Phalcon\Http\Response;
class AjaxController extends ControllerBase
{
public function insuranceAction()
{
$insurance = $this->request->get('insurance');
$this->session->set('insurance', $insurance === 'true');
$response = new Response();
$response->setJsonContent([
'status' => 'ok',
'insurance' => $insurance,
]);
return $response;
}
}
Regards