Loader
This class implements a Twig template loader for the CMS.
class Cms\Twig\Loader
extends System\Twig\Loader
implements
Twig\Loader\LoaderInterface
Properties
protected
$fallbackCache
:
array
= []
Cache
protected $obj : Cms\Classes\CmsCompoundObject
A CMS object to load the template from.
public
static
$allowInclude
:
bool
= false
Inherited from
Loader
Allow any local file
protected
$cache
:
array
= []
Inherited from
Loader
Cache
Methods
public exists (string $name) : bool
Checks that the template exists.
Parameters
Property | Type | Description |
---|---|---|
$name | string |
string
|
Returns
bool
public getCacheKey (string $name) : string
Returns the Twig cache key.
Parameters
Property | Type | Description |
---|---|---|
$name | string |
string
|
Returns
string
public getFilename (string $name) : string
Returns the file name of the loaded template.
Parameters
Property | Type | Description |
---|---|---|
$name | string |
string
|
Returns
string
public getSourceContext (string $name) : Twig\Source
Returns the Twig content string.
This step is cached internally by Twig.
Parameters
Property | Type | Description |
---|---|---|
$name | string |
string
|
Returns
Twig\Source
public isFresh (string $name, integer $time) : bool
Determines if the content is fresh.
Parameters
Property | Type | Description |
---|---|---|
$name | string |
string
The template name |
$time | integer |
integer
The time to check against the template |
Returns
bool
public setObject (Cms\Contracts\CmsObject $obj) : void
Sets a CMS object to load the template from.
Parameters
Property | Type | Description |
---|---|---|
$obj | Cms\Contracts\CmsObject |
Cms\Contracts\CmsObject
Specifies the CMS object. |
Returns
void
protected findFallbackObject (string $name) : Cms\Classes\Partial | bool
Looks up a fallback CMS partial object.
Parameters
Property | Type | Description |
---|---|---|
$name | string |
string
The filename to attempt to load a fallback CMS partial for |
Returns
Cms\Classes\Partial | bool
Returns false if a CMS partial can't be found
protected validateCmsObject (string $name) : bool
Internal method that checks if the template name matches the loaded object, with fallback support to partials.
Parameters
Property | Type | Description |
---|---|---|
$name | string |
string
|
Returns
bool
protected findTemplate (string $name) : string
Inherited from
Loader
Gets the path of a view file.
Parameters
Property | Type | Description |
---|---|---|
$name | string |
string
|
Returns
string
Copyright © 2023 Winter CMS