File: src/Response/AbstractResponse.php

Recommend this page to a friend!
  Classes of Thierry Feuzeu  >  Jaxon  >  src/Response/AbstractResponse.php  >  Download  
File: src/Response/AbstractResponse.php
Role: Class source
Content type: text/plain
Description: Class source
Class: Jaxon
Call PHP classes from JavaScript using AJAX
Author: By
Last change:
Date: 7 months ago
Size: 2,413 bytes
 

Contents

Class file image Download
<?php

namespace Jaxon\Response;

abstract class
AbstractResponse
{
    use \
Jaxon\Features\Config;

   
/**
     * Get the content type, which is always set to 'text/json'
     *
     * @return string
     */
   
abstract public function getContentType();

   
/**
     * Get the configured character encoding
     *
     * @return string
     */
   
public function getCharacterEncoding()
    {
        return
trim($this->getOption('core.encoding'));
    }

   
/**
     * Used internally to generate the response headers
     *
     * @return void
     */
   
public function sendHeaders()
    {
        if(
jaxon()->di()->getRequestHandler()->requestMethodIsGet())
        {
           
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
           
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
           
header("Cache-Control: no-cache, must-revalidate");
           
header("Pragma: no-cache");
        }

       
$sCharacterSet = '';
       
$sCharacterEncoding = $this->getCharacterEncoding();
        if(
is_string($sCharacterEncoding) && strlen($sCharacterEncoding) > 0)
        {
           
$sCharacterSet = '; charset="' . $sCharacterEncoding . '"';
        }

       
header('content-type: ' . $this->getContentType() . ' ' . $sCharacterSet);
    }

   
/**
     * Merge the response commands from the specified <Response> object with
     * the response commands in this <Response> object
     *
     * @param AbstractResponse $mCommands The <Response> object
     * @param boolean $bBefore Add the new commands to the beginning of the list
     *
     * @return void
     */
   
public function appendResponse(AbstractResponse $mCommands, $bBefore = false)
    {
    }

   
/**
     * Add a command to display a debug message to the user
     *
     * @param string $sMessage The message to be displayed
     *
     * @return AbstractResponse
     */
   
abstract public function debug($sMessage);

   
/**
     * Return the output, generated from the commands added to the response, that will be sent to the browser
     *
     * @return string
     */
   
abstract public function getOutput();

   
/**
     * Print the output, generated from the commands added to the response, that will be sent to the browser
     *
     * @return void
     */
   
public function printOutput()
    {
        print
$this->getOutput();
    }
}


For more information send a message to info at phpclasses dot org.