PHP Class Slim\Views\PhpRenderer

Show file Open project: geggleto/slim-renderer

Protected Properties

Property Type Description
$attributes array
$templatePath string

Public Methods

Method Description
__construct ( string $templatePath = "", array $attributes = [] ) SlimRenderer constructor.
addAttribute ( $key, $value ) Add an attribute
fetch ( $template, array $data = [] ) : mixed Renders a template and returns the result as a string
getAttribute ( $key ) : mixed Retrieve an attribute
getAttributes ( ) : array Get the attributes for the renderer
getTemplatePath ( ) : string Get the template path
render ( Psr\Http\Message\ResponseInterface $response, string $template, array $data = [] ) : Psr\Http\Message\ResponseInterface Render a template
setAttributes ( array $attributes ) Set the attributes for the renderer
setTemplatePath ( string $templatePath ) Set the template path

Protected Methods

Method Description
protectedIncludeScope ( string $template, array $data )

Method Details

__construct() public method

SlimRenderer constructor.
public __construct ( string $templatePath = "", array $attributes = [] )
$templatePath string
$attributes array

addAttribute() public method

Add an attribute
public addAttribute ( $key, $value )
$key
$value

fetch() public method

cannot contain template as a key throws RuntimeException if $templatePath . $template does not exist
public fetch ( $template, array $data = [] ) : mixed
$template
$data array
return mixed

getAttribute() public method

Retrieve an attribute
public getAttribute ( $key ) : mixed
$key
return mixed

getAttributes() public method

Get the attributes for the renderer
public getAttributes ( ) : array
return array

getTemplatePath() public method

Get the template path
public getTemplatePath ( ) : string
return string

protectedIncludeScope() protected method

protected protectedIncludeScope ( string $template, array $data )
$template string
$data array

render() public method

$data cannot contain template as a key throws RuntimeException if $templatePath . $template does not exist
public render ( Psr\Http\Message\ResponseInterface $response, string $template, array $data = [] ) : Psr\Http\Message\ResponseInterface
$response Psr\Http\Message\ResponseInterface
$template string
$data array
return Psr\Http\Message\ResponseInterface

setAttributes() public method

Set the attributes for the renderer
public setAttributes ( array $attributes )
$attributes array

setTemplatePath() public method

Set the template path
public setTemplatePath ( string $templatePath )
$templatePath string

Property Details

$attributes protected property

protected array $attributes
return array

$templatePath protected property

protected string $templatePath
return string