Loader

This class implements a Twig template loader for the CMS.

 class Cms\Twig\Loader
extends System\Twig\Loader
implements 
    Twig\Loader\LoaderInterface

Extends

Class Description
Loader

This class implements a Twig template loader for the core system and backend.

Properties

protected $fallbackCache : array

Cache

protected $obj : Cms\Classes\CmsCompoundObject

A CMS object to load the template from.

inherited public static $allowInclude : bool

Inherited from Loader

Allow any local file

inherited protected $cache : array

Inherited from Loader

Cache

Methods

public exists (string $name) : bool

Checks that the template exists.

Parameters
Property Description
$name
string
Returns
bool

public getCacheKey (string $name) : string

Returns the Twig cache key.

Parameters
Property Description
$name
string
Returns
string

public getFilename (string $name) : string

Returns the file name of the loaded template.

Parameters
Property Description
$name
string
Returns
string

public getSourceContext (string $name) : Twig\Source

Returns the Twig content string.

This step is cached internally by Twig.

Parameters
Property Description
$name
string
Returns
Twig\Source

public isFresh (string $name, integer $time) : bool

Determines if the content is fresh.

Parameters
Property Description
$name
string

The template name

$time
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 Description
$obj
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 Description
$name
string

The filename to attempt to load a fallback CMS partial for

Returns

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 Description
$name
string
Returns
bool

inherited protected findTemplate (string $name) : string

Inherited from Loader

Gets the path of a view file.

Parameters
Property Description
$name
string
Returns
string
Copyright © 2024 Winter CMS