PHP Class Bolt\Response\BoltResponse

Deprecation: Deprecated since 3.3, use TemplateResponse instead.
Author: Ross Riley ([email protected])
Inheritance: extends Symfony\Component\HttpFoundation\Response
ファイルを表示 Open project: bolt/bolt Class Usage Examples

Protected Properties

Property Type Description
$compiled
$context
$stopwatch Symfony\Component\Stopwatch\Stopwatch | null
$template Twig_Template

Public Methods

Method Description
__construct ( Twig_Template $template, array $context = [], array $globals = [], integer $status = 200, array $headers = [] ) Constructor.
__toString ( ) : string Returns the Response as a string.
addGlobalContext ( string $name, mixed $value ) Adds a global to the template
addGlobals ( array $globals ) Adds globals to the template
compile ( ) Compiles the template using the context.
create ( Twig_Template $template = null, array $context = [], array $globals = [], integer $status = 200, array $headers = [] ) : BoltResponse Factory method for chainability
getContent ( ) : string Gets HTML content for the response.
getContext ( ) : array Returns the context.
getGlobalContext ( ) : array Gets globals from the template.
getTemplate ( ) : Twig_Template Returns the template.
getTemplateName ( ) : string Gets the name of the main loaded template.
isCompiled ( ) : boolean Returns whether the response has been compiled
setContext ( array $context ) Sets the context variables for this Response.
setStopwatch ( Symfony\Component\Stopwatch\Stopwatch $stopwatch )
setTemplate ( Twig_Template $template ) Sets the Renderer used to create this Response.

Private Methods

Method Description
handleException ( Exception $e ) : string The __toString method isn't allowed to throw exceptions so we turn them into an error instead

Method Details

__construct() public method

Constructor.
public __construct ( Twig_Template $template, array $context = [], array $globals = [], integer $status = 200, array $headers = [] )
$template Twig_Template An object that is able to render a template with context
$context array An array of context variables
$globals array An array of global context variables
$status integer The response status code
$headers array An array of response headers

__toString() public method

Returns the Response as a string.
public __toString ( ) : string
return string The Response as HTML

addGlobalContext() public method

Adds a global to the template
public addGlobalContext ( string $name, mixed $value )
$name string
$value mixed

addGlobals() public method

Adds globals to the template
public addGlobals ( array $globals )
$globals array

compile() public method

Compiles the template using the context.
public compile ( )

create() public static method

Factory method for chainability
public static create ( Twig_Template $template = null, array $context = [], array $globals = [], integer $status = 200, array $headers = [] ) : BoltResponse
$template Twig_Template An object that is able to render a template with context
$context array An array of context variables
$globals array An array of global context variables
$status integer The response status code
$headers array An array of response headers
return BoltResponse

getContent() public method

Gets HTML content for the response.
public getContent ( ) : string
return string

getContext() public method

Returns the context.
public getContext ( ) : array
return array

getGlobalContext() public method

Gets globals from the template.
public getGlobalContext ( ) : array
return array

getTemplate() public method

Returns the template.
public getTemplate ( ) : Twig_Template
return Twig_Template

getTemplateName() public method

Gets the name of the main loaded template.
public getTemplateName ( ) : string
return string

isCompiled() public method

Returns whether the response has been compiled
public isCompiled ( ) : boolean
return boolean

setContext() public method

Sets the context variables for this Response.
public setContext ( array $context )
$context array

setStopwatch() public method

public setStopwatch ( Symfony\Component\Stopwatch\Stopwatch $stopwatch )
$stopwatch Symfony\Component\Stopwatch\Stopwatch

setTemplate() public method

Sets the Renderer used to create this Response.
public setTemplate ( Twig_Template $template )
$template Twig_Template A template object

Property Details

$compiled protected_oe property

protected $compiled

$context protected_oe property

protected $context

$stopwatch protected_oe property

protected Stopwatch,Symfony\Component\Stopwatch|null $stopwatch
return Symfony\Component\Stopwatch\Stopwatch | null

$template protected_oe property

protected Twig_Template $template
return Twig_Template