Advertisement
Guest User

Untitled

a guest
Jul 17th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. // Return a JsonModel from the controller action
  2. // To send JSON to the client when the Accept header isn’t application/json,
  3. // we use a JsonModel in a controller action like this:
  4.  
  5. namespace Application\Controller;
  6.  
  7. use Zend\Mvc\Controller\ActionController;
  8. use Zend\View\Model\ViewModel;
  9. use Zend\View\Model\JsonModel;
  10.  
  11. class IndexController extends ActionController
  12. {
  13.  
  14. public function indexAction()
  15. {
  16.  
  17. $result = new JsonModel(array(
  18. 'some_parameter' => 'some value',
  19. 'success'=>true,
  20. ));
  21.  
  22. return $result;
  23.  
  24. }
  25.  
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement