PHP Class Box\Brainy\Templates\Template

Inheritance: extends TemplateBase
ファイルを表示 Open project: box/brainy Class Usage Examples

Public Properties

Property Type Description
$compile_id string $compile_id
$compiled
$properties array special compiled template properties
$required_plugins array required plugins
$source
$template_resource string Full template resource

Public Methods

Method Description
__construct ( string $tplResource, Box\Brainy\Brainy $brainy, Template $parent = null, mixed $compileID = null, boolean | void $suppressData = false ) Create template data object
compileTemplateSource ( ) : string Compiles the template
createTemplateCodeFrame ( string $content = '' ) : string Create code frame for compiled and cached templates
decodeProperties ( array $properties ) : boolean This function is executed automatically when a compiled or cached template file is included
getScopePointer ( integer $scope ) : mixed Get parent or root of template parent chain
mustCompile ( ) : boolean Returns if the current template must be compiled by the Smarty compiler
recompileAndLoadCopy ( ) : void Recompiles the template and also writes a copy of the compiled code to a temporary destination to load from. This is so that stale compiled code will be refreshed in HHVM, which does not support requiring the same file twice even if it has been changed.
writeFile ( string $_filepath, string $_contents, Box\Brainy\Brainy $smarty ) : boolean Writes file in a safe way to disk

Method Details

__construct() public method

Some of the global Smarty settings copied to template scope It load the required template resources and cacher plugins
public __construct ( string $tplResource, Box\Brainy\Brainy $brainy, Template $parent = null, mixed $compileID = null, boolean | void $suppressData = false )
$tplResource string template resource string
$brainy Box\Brainy\Brainy Brainy instance
$parent Template back pointer to parent object with variables or null
$compileID mixed compile id or null
$suppressData boolean | void Prevents data from being copied into the variable scope

compileTemplateSource() public method

Compiles the template
public compileTemplateSource ( ) : string
return string The compiled template source

createTemplateCodeFrame() public method

Create code frame for compiled and cached templates
public createTemplateCodeFrame ( string $content = '' ) : string
$content string optional template content
return string

decodeProperties() public method

This function is executed automatically when a compiled or cached template file is included
public decodeProperties ( array $properties ) : boolean
$properties array special template properties
return boolean flag if compiled or cache file is valid

getScopePointer() public method

Get parent or root of template parent chain
public getScopePointer ( integer $scope ) : mixed
$scope integer pqrent or root scope
return mixed object

mustCompile() public method

It does compare the timestamps of template source and the compiled templates
public mustCompile ( ) : boolean
return boolean true if the template must be compiled

recompileAndLoadCopy() public method

Recompiles the template and also writes a copy of the compiled code to a temporary destination to load from. This is so that stale compiled code will be refreshed in HHVM, which does not support requiring the same file twice even if it has been changed.
public recompileAndLoadCopy ( ) : void
return void

writeFile() public static method

Writes file in a safe way to disk
public static writeFile ( string $_filepath, string $_contents, Box\Brainy\Brainy $smarty ) : boolean
$_filepath string complete filepath
$_contents string file content
$smarty Box\Brainy\Brainy smarty instance
return boolean true

Property Details

$compile_id public_oe property

$compile_id
public string $compile_id
return string

$compiled public_oe property

public $compiled

$properties public_oe property

special compiled template properties
public array $properties
return array

$required_plugins public_oe property

required plugins
public array $required_plugins
return array

$source public_oe property

public $source

$template_resource public_oe property

Full template resource
public string $template_resource
return string