PHP Class Airship\Engine\Lens

For MVC developers, this is analogous to a View
Inheritance: use trait Airship\Engine\Bolt\Log
Show file Open project: paragonie/airship Class Usage Examples

Public Methods

Method Description
__construct ( Twig_Environment $twigEnv ) Lens constructor.
addGlobal ( string $key, &mixed $value ) : self Add a global variable to Twig
append ( string $key, mixed $val ) : self Maintain an array of values for later rendering, appending the supplied value.
display ( string $base, array $params = [], string $mime = 'text/html;charset=UTF-8' ) : boolean Render a template and print out its contents.
filter ( string $name, callable $func = null ) : self Add a filter to Twig
func ( string $name, callable $func = null, array $is_safe = ['html'] ) : self Add a function to our Twig environment
listFilters ( ) : array Get all filters
loadMotifCargo ( string $name ) : self Load the cargo for these motifs
loadMotifConfig ( string $name ) : self Load the config for this motif
prepend ( string $key, mixed $val ) : self Maintain an array of values for later rendering, prepending the supplied value.
registerGlobal ( string $name, &array &$value ) : self Register an array or object as a Twig global.
render ( string $base, array $params = [] ) : string Render a template and return its contents as a string.
resetBaseTemplate ( ) : self Reset the base template
sendStandardHeaders ( string $mimeType ) : void Send HTTP headers
setActiveMotif ( string $name ) : boolean Set the active motif
setBaseTemplate ( string $name ) : self Override the base template
store ( string $key, mixed $val ) : self Persist state for later rendering.
unsafeDisplay ( string $file, array $params = [], string $mime = 'text/html;charset=UTF-8' ) : boolean Render a template and print out its contents without sanity checks.
unsafeRender ( string $file, array $params = [] ) : string Render a template and print out its contents without sanity checks.

Method Details

__construct() public method

Lens constructor.
public __construct ( Twig_Environment $twigEnv )
$twigEnv Twig_Environment

addGlobal() public method

Add a global variable to Twig
public addGlobal ( string $key, &mixed $value ) : self
$key string
$value &mixed
return self

append() public method

Maintain an array of values for later rendering, appending the supplied value.
public append ( string $key, mixed $val ) : self
$key string Index
$val mixed Value
return self

display() public method

Render a template and print out its contents.
public display ( string $base, array $params = [], string $mime = 'text/html;charset=UTF-8' ) : boolean
$base string Template to render (e.g. 'index' or 'dir/index')
$params array Parameters to pass towards the array
$mime string MIME type header to transmit
return boolean

filter() public method

Add a filter to Twig
public filter ( string $name, callable $func = null ) : self
$name string - Name to access n Twig
$func callable - function to apply
return self

func() public method

Add a function to our Twig environment
public func ( string $name, callable $func = null, array $is_safe = ['html'] ) : self
$name string - Name to access in Twig
$func callable - function definition
$is_safe array
return self

listFilters() public method

Get all filters
public listFilters ( ) : array
return array

loadMotifCargo() public method

Load the cargo for these motifs
public loadMotifCargo ( string $name ) : self
$name string
return self

loadMotifConfig() public method

Load the config for this motif
public loadMotifConfig ( string $name ) : self
$name string
return self

prepend() public method

Maintain an array of values for later rendering, prepending the supplied value.
public prepend ( string $key, mixed $val ) : self
$key string Index
$val mixed Value
return self

registerGlobal() public method

Register an array or object as a Twig global.
public registerGlobal ( string $name, &array &$value ) : self
$name string Name to access in Twig (by ref)
$value &array
return self

render() public method

Render a template and return its contents as a string.
public render ( string $base, array $params = [] ) : string
$base string Template to render (e.g. 'index' or 'dir/index')
$params array Parameters to pass towards the array
return string

resetBaseTemplate() public method

Reset the base template
public resetBaseTemplate ( ) : self
return self

sendStandardHeaders() public method

Send HTTP headers
public sendStandardHeaders ( string $mimeType ) : void
$mimeType string
return void

setActiveMotif() public method

Set the active motif
public setActiveMotif ( string $name ) : boolean
$name string
return boolean

setBaseTemplate() public method

Override the base template
public setBaseTemplate ( string $name ) : self
$name string
return self

store() public method

Persist state for later rendering.
public store ( string $key, mixed $val ) : self
$key string Index
$val mixed Value
return self

unsafeDisplay() public method

Render a template and print out its contents without sanity checks.
public unsafeDisplay ( string $file, array $params = [], string $mime = 'text/html;charset=UTF-8' ) : boolean
$file string Template to render (e.g. 'index' or 'dir/index')
$params array Parameters to pass towards the array
$mime string MIME type
return boolean

unsafeRender() public method

Render a template and print out its contents without sanity checks.
public unsafeRender ( string $file, array $params = [] ) : string
$file string Template to render (e.g. 'index' or 'dir/index')
$params array Parameters to pass towards the array
return string