\Charcoal\View\TwigTwigLoader

The Charcoal View Twig Loader implements both Twig_LoaderInterface and its own LoaderInterface.

Summary

Methods
Properties
Constants
__construct()
load()
getSource()
getSourceContext()
exists()
getCacheKey()
isFresh()
No public properties found
No constants found
basePath()
paths()
findTemplateFile()
filenameFromIdent()
No protected properties found
N/A
setPaths()
setBasePath()
addPath()
resolvePath()
$basePath
$paths
N/A

Properties

$basePath

$basePath : string

Type

string

$paths

$paths : array<mixed,string>

Type

array<mixed,string>

Methods

__construct()

__construct(array  $data = null) 

Default constructor, if none is provided by the concrete class implementations.

Required dependencies

  • logger A PSR-3 logger

Parameters

array $data

The class dependencies map.

load()

load(string  $ident) : string

Load a template content

Parameters

string $ident

The template ident to load and render.

Throws

\InvalidArgumentException

If the dynamic template identifier is not a string.

Returns

string

getSource()

getSource(string  $name) : string

Twig_LoaderInterface > getSource()

Gets the source code of a template, given its name.

Parameters

string $name

The name of the template to load.

Returns

string —

The template source code.

getSourceContext()

getSourceContext(string  $name) : \Twig_Source

Twig_LoaderInterface > getSourceContext()

Gets the source code of a template, given its name. For Twig 2.x

Parameters

string $name

The name of the template to load.

Returns

\Twig_Source —

The template source object.

exists()

exists(string  $name) : boolean

Twig_LoaderInterface > exists()

For Twig 2.x

Parameters

string $name

The name of the template to load.

Returns

boolean

getCacheKey()

getCacheKey(string  $name) : string

Twig_LoaderInterface > getCacheKey()

Gets the cache key to use for the cache for a given template name.

Parameters

string $name

The name of the template to load.

Returns

string —

The cache key

isFresh()

isFresh(string  $name, integer  $time) : boolean

Twig_LoaderInterface > isFresh()

Returns true if the template is still fresh.

Parameters

string $name

The template name.

integer $time

The last modification time of the cached template.

Returns

boolean

basePath()

basePath() : string

Returns

string

paths()

paths() : array<mixed,string>

Returns

array<mixed,string>

findTemplateFile()

findTemplateFile(string  $ident) : string|null

Get the template file (full path + filename) to load from an ident.

This method first generates the filename for an identifier and search for it in all of the loader's paths.

Parameters

string $ident

The template identifier to load.

Throws

\InvalidArgumentException

If the template ident is not a string.

Returns

string|null —

The full path + filename of the found template. Null if nothing was found.

filenameFromIdent()

filenameFromIdent(string  $ident) : string

Convert an identifier to a file path.

Parameters

string $ident

The identifier to convert.

Returns

string

setPaths()

setPaths(array<mixed,string>  $paths) : \Charcoal\View\LoaderInterface

Parameters

array<mixed,string> $paths

The list of path to add.

Returns

\Charcoal\View\LoaderInterface

Chainable

setBasePath()

setBasePath(string  $basePath) : \Charcoal\View\LoaderInterface

Parameters

string $basePath

The base path to set.

Throws

\InvalidArgumentException

If the base path parameter is not a string.

Returns

\Charcoal\View\LoaderInterface

Chainable

addPath()

addPath(string  $path) : \Charcoal\View\LoaderInterface

Parameters

string $path

The path to add to the load.

Returns

\Charcoal\View\LoaderInterface

Chainable

resolvePath()

resolvePath(string  $path) : string

Parameters

string $path

The path to resolve.

Throws

\InvalidArgumentException

If the path argument is not a string.

Returns

string