Pionia Core

TemplateEngine
in package
implements TemplateEngineInterface Uses Cacheable

Table of Contents

Interfaces

TemplateEngineInterface

Properties

$cachePrefix  : string
The cache prefix to use for caching.
$cacheTtl  : int
The cache ttl to use for caching.
$blocks  : array<string|int, mixed>
$cache_enabled  : bool
$cacheInstance  : PioniaCache|null
The cache instance to use for caching.

Methods

cache()  : bool|mixed
Caches the value if the value is not null.
ClearByKeys()  : bool
Clear the cache.
clearCache()  : void
Clear the cached files
compileEscapedEchos()  : array<string|int, mixed>|string|null
deleteCache()  : bool
Delete the cache for the key.
getCache()  : mixed
getCacheInstance()  : PioniaCache|null
hasCache()  : bool
Check if the cache has the key.
parse()  : string
Parse the template file and return the content as string
setCache()  : bool
setCacheInstance()  : void
Set the cache instance to use for caching.
view()  : void
Render a template file
cached()  : string
cachePath()  : string
cleanCacheKey()  : string
compileBlock()  : mixed
compileCode()  : array<string|int, mixed>|string|null
compileEchos()  : array<string|int, mixed>|string|null
compilePHP()  : array<string|int, mixed>|string|null
compileYield()  : array<string|int, mixed>|string|null
getKeyName()  : string
Converts the key to snake case and appends the current class prefix if it does not exist.
includeFiles()  : array<string|int, mixed>|string|null
logger()  : LoggerInterface|null

Properties

$cachePrefix

The cache prefix to use for caching.

public string $cachePrefix = __CLASS__

$cacheTtl

The cache ttl to use for caching.

public int $cacheTtl = 60

Defaults to 60 seconds.

$cacheInstance

The cache instance to use for caching.

private PioniaCache|null $cacheInstance = null

Methods

cache()

Caches the value if the value is not null.

public cache(string $key[, mixed $value = null ][, mixed $ttl = null ][, bool|null $exact = false ]) : bool|mixed
Parameters
$key : string

The key to cache

$value : mixed = null

The value to cache

$ttl : mixed = null

The time to live for the cache

$exact : bool|null = false

If passed, the key won't be parsed at all, it will be cached as is.

Return values
bool|mixed

ClearByKeys()

Clear the cache.

public ClearByKeys(array<string|int, mixed> $keys[, bool|null $exact = false ]) : bool
Parameters
$keys : array<string|int, mixed>

The keys to clear

$exact : bool|null = false

If passed, the keys won't be parsed at all

Return values
bool

clearCache()

Clear the cached files

public static clearCache() : void

compileEscapedEchos()

public static compileEscapedEchos(mixed $code) : array<string|int, mixed>|string|null
Parameters
$code : mixed
Return values
array<string|int, mixed>|string|null

deleteCache()

Delete the cache for the key.

public deleteCache(string $key[, bool $exact = false ]) : bool
Parameters
$key : string

The key to delete

$exact : bool = false

If passed, the key won't be parsed at all

Return values
bool

getCache()

public getCache( $key[, bool|null $exact = false ]) : mixed
Parameters
$key :
$exact : bool|null = false

hasCache()

Check if the cache has the key.

public hasCache( $key[, bool|null $exact = false ]) : bool

Will not throw an exception if the key is not set or the cache is not activated.

Parameters
$key :
$exact : bool|null = false
Return values
bool

parse()

Parse the template file and return the content as string

public parse(mixed $file[, mixed $data = array() ]) : string
Parameters
$file : mixed
$data : mixed = array()
Return values
string

setCache()

public setCache(string $key, mixed $value[, mixed $ttl = null ][, bool|null $exact = false ]) : bool
Parameters
$key : string
$value : mixed
$ttl : mixed = null
$exact : bool|null = false
Return values
bool

setCacheInstance()

Set the cache instance to use for caching.

public setCacheInstance(PioniaCache|null $cache) : void
Parameters
$cache : PioniaCache|null

view()

Render a template file

public view(mixed $file[, mixed $data = array() ]) : void
Parameters
$file : mixed
$data : mixed = array()

cached()

private cached(mixed $file) : string
Parameters
$file : mixed
Return values
string

cleanCacheKey()

private cleanCacheKey(string $key) : string
Parameters
$key : string
Return values
string

compileBlock()

private compileBlock(mixed $code) : mixed
Parameters
$code : mixed

compileCode()

private compileCode(mixed $code) : array<string|int, mixed>|string|null
Parameters
$code : mixed
Return values
array<string|int, mixed>|string|null

compileEchos()

private compileEchos(mixed $code) : array<string|int, mixed>|string|null
Parameters
$code : mixed
Return values
array<string|int, mixed>|string|null

compilePHP()

private compilePHP(mixed $code) : array<string|int, mixed>|string|null
Parameters
$code : mixed
Return values
array<string|int, mixed>|string|null

compileYield()

private compileYield(mixed $code) : array<string|int, mixed>|string|null
Parameters
$code : mixed
Return values
array<string|int, mixed>|string|null

getKeyName()

Converts the key to snake case and appends the current class prefix if it does not exist.

private getKeyName(string $key) : string
Parameters
$key : string
Return values
string

includeFiles()

private includeFiles(mixed $file) : array<string|int, mixed>|string|null
Parameters
$file : mixed
Return values
array<string|int, mixed>|string|null

logger()

private logger() : LoggerInterface|null
Return values
LoggerInterface|null

        
On this page

Search results