|
const | TPL_CACHE_VARS = 100 |
|
const | TPL_USE_VARS_ONLY = 101 |
|
const | TPL_NO_CACHE_VARS = 102 |
|
const | TPL_RETURN = 200 |
|
const | TPL_OUTPUT = 201 |
|
|
| combineData (array $data, int $cacheData) |
|
| load (string $template, array $data) |
|
|
| $response = null |
|
| $logger = null |
|
| $tplExt = "" |
|
| $template = "" |
|
| $templateDir = "" |
|
| $cachedData = [] |
|
SlaxWeb\View\AbstractLoader::__construct |
( |
Response |
$response, |
|
|
Logger |
$logger |
|
) |
| |
Class constructor
Assigns the dependant Response object to the class property. The View loader will automatically add template contents to as response body.
- Parameters
-
\Symfony\Component\HttpFoundation\Response | $response | Response object |
\Psr\Log\LoggerInterface | $logger | PSR4 compatible Logger object |
SlaxWeb\View\AbstractLoader::combineData |
( |
array |
$data, |
|
|
int |
$cacheData |
|
) |
| |
|
protected |
Combine data
Combines the received data and the already cached data, depending on the *$cacheData* parameter passed as the second parameter. The first parameter holds an array of data that will be combined with the cached data.
- Parameters
-
array | $data | Template data to be passed to the template. Default [] |
int | $cacheData | Cache template data. |
- Returns
- array
SlaxWeb\View\AbstractLoader::load |
( |
string |
$template, |
|
|
array |
$data |
|
) |
| |
|
abstractprotected |
Load template
Load the template file. Defined as abstract, because each loader will load its template files in a different way.
- Parameters
-
string | $template | Path to the template file |
array | $data | View data |
- Returns
- string
SlaxWeb\View\AbstractLoader::render |
( |
array |
$data = [] , |
|
|
int |
$return = self::TPL_OUTPUT , |
|
|
int |
$cacheData = self::TPL_CACHE_VARS |
|
) |
| |
Render the template
Loads the template file with the retrieved data array, and returns the rendered template. By default the template data is cached in the internal property for all future renders of that same requests. To disable the cached vars and load the template only with the currently passed in data, constant TPL_NO_CACHE_VARS has to be sent as the third parameter.
The Render method will automatically add contents of the rendered template file to the Response object as response body. If you wish to retrieve the contents back, pass in constant TPL_RETURN as the second parameter. When the rendered template is only added to the Response object, an empty string is returned.
- Parameters
-
array | $data | Template data to be passed to the template. Default [] |
int | $return | Output or return rendered template. Default self::TPL_OUTPUT |
int | $cacheData | Cache template data. Default self::TPL_CACHE_VARS |
- Returns
- string
SlaxWeb
SlaxWeb\View\AbstractLoader::setTemplate |
( |
string |
$template | ) |
|
Set the template
Sets the template filename.
- Parameters
-
string | $template | Name of the template file |
- Returns
- self
SlaxWeb\View\AbstractLoader::setTemplateDir |
( |
string |
$templateDir | ) |
|
Set the template directory
Sets the template directory name.
- Parameters
-
string | $templateDir | Name of the template directory |
- Returns
- self
SlaxWeb\View\AbstractLoader::setTemplateExt |
( |
string |
$tplExt | ) |
|
Set Template File Extension
Sets the template file extension to the provided value. It automatically strips the leading dot if present.
- Parameters
-
string | $tplExt | Template File Extension |
- Returns
- self
const SlaxWeb\View\AbstractLoader::TPL_CACHE_VARS = 100 |
Template variables caching
const SlaxWeb\View\AbstractLoader::TPL_RETURN = 200 |
Template render output control
The documentation for this class was generated from the following file:
- /opt/slax0rDev/slaxweb/view/src/AbstractLoader.php