PHP Class Webiny\Component\TemplateEngine\Bridge\Smarty\Smarty

Inheritance: implements Webiny\Component\TemplateEngine\Bridge\TemplateEngineInterface, use trait Webiny\Component\ServiceManager\ServiceManagerTrait
Show file Open project: Webiny/Framework Class Usage Examples

Public Methods

Method Description
__construct ( ConfigObject $config ) Base constructor.
assign ( string $var, mixed $value ) : void Assign a variable and its value into the template engine.
fetch ( string $template, array $parameters = [] ) : string Fetch the template from the given location, parse it and return the output.
getCacheDir ( ) : string Returns the current cache dir.
getCompileDir ( ) : string Returns the current compile dir.
getForceCompile ( ) : boolean Returns the current value of force_compile flag.
getMergeCompiledIncludes ( ) : boolean Returns the current value of inheritance_merge_compiled_includes flag.
getTemplateDir ( ) : string Returns the current template dir.
registerExtensions ( ) Gets the registered Smarty extensions that have been registered over the ServiceManager and assigns them to current Smarty instance.
registerPlugin ( Plugin $plugin ) : void Register a plugin for the template engine.
render ( string $template, array $parameters = [] ) : void Fetch the template from the given location, parse it and output the result to the browser.
setCacheDir ( string $cacheDir ) Set Smarty cache dir.
setCompileDir ( string $compileDir ) Set Smarty compile dir.
setForceCompile ( boolean $forceCompile ) Force to re-compile the templates on every refresh.
setMergeCompiledIncludes ( boolean $mergeCompiledIncludes ) Force to re-compile the templates on every refresh.
setTemplateDir ( string $templateDir ) : void Root path where the templates are stored.

Method Details

__construct() public method

Base constructor.
public __construct ( ConfigObject $config )
$config Webiny\Component\Config\ConfigObject Configuration for the template engine.

assign() public method

Assign a variable and its value into the template engine.
public assign ( string $var, mixed $value ) : void
$var string Variable name.
$value mixed Variable value.
return void

fetch() public method

Fetch the template from the given location, parse it and return the output.
public fetch ( string $template, array $parameters = [] ) : string
$template string Path to the template.
$parameters array A list of parameters to pass to the template.
return string Parsed template.

getCacheDir() public method

Returns the current cache dir.
public getCacheDir ( ) : string
return string Absolute path to cache dir.

getCompileDir() public method

Returns the current compile dir.
public getCompileDir ( ) : string
return string Absolute path to compile dir.

getForceCompile() public method

Returns the current value of force_compile flag.
public getForceCompile ( ) : boolean
return boolean

getMergeCompiledIncludes() public method

Returns the current value of inheritance_merge_compiled_includes flag.

getTemplateDir() public method

Returns the current template dir.
public getTemplateDir ( ) : string
return string Absolute path to template dir.

registerExtensions() public method

NOTE: This function is automatically called by the class constructor.
public registerExtensions ( )

registerPlugin() public method

Register a plugin for the template engine.
public registerPlugin ( Plugin $plugin ) : void
$plugin Webiny\Component\TemplateEngine\Plugin
return void

render() public method

Fetch the template from the given location, parse it and output the result to the browser.
public render ( string $template, array $parameters = [] ) : void
$template string Path to the template.
$parameters array A list of parameters to pass to the template.
return void

setCacheDir() public method

Set Smarty cache dir.
public setCacheDir ( string $cacheDir )
$cacheDir string Absolute path where to store cache files.

setCompileDir() public method

Set Smarty compile dir.
public setCompileDir ( string $compileDir )
$compileDir string Absolute path where to store compiled files.

setForceCompile() public method

Force to re-compile the templates on every refresh.
public setForceCompile ( boolean $forceCompile )
$forceCompile boolean

setMergeCompiledIncludes() public method

Force to re-compile the templates on every refresh.
public setMergeCompiledIncludes ( boolean $mergeCompiledIncludes )
$mergeCompiledIncludes boolean

setTemplateDir() public method

Root path where the templates are stored.
public setTemplateDir ( string $templateDir ) : void
$templateDir string
return void