Esempio n. 1
0
 /**
  * Pre process
  *
  * @return void
  * @throws ApplicationException
  */
 protected function preProcess()
 {
     Router::process();
     // disable Layout for XmlHttpRequests
     if (Request::isXmlHttpRequest()) {
         $this->layoutFlag = false;
     }
     // switch to JSON response based on Accept header
     if (Request::getAccept([Request::TYPE_HTML, Request::TYPE_JSON]) == Request::TYPE_JSON) {
         $this->layoutFlag = false;
         Response::switchType('JSON');
     }
 }
Esempio n. 2
0
 /**
  * Pre process
  * @return void
  */
 protected function preProcess()
 {
     Router::process();
     Response::switchType('CLI');
 }
Esempio n. 3
0
<?php

/**
 * Bluz Framework Component
 *
 * @copyright Bluz PHP Team
 * @link https://github.com/bluzphp/framework
 */
/**
 * @namespace
 */
namespace Bluz\Controller\Helper;

use Bluz\Application\Application;
use Bluz\Controller\Controller;
use Bluz\Proxy\Response;
/**
 * Switch to JSON content
 *
 * @return void
 */
return function () {
    /**
     * @var Controller $this
     */
    Application::getInstance()->useLayout(false);
    Response::switchType('JSON');
};