\Charcoal\View\PhpPhpLoader

The PHP template loader finds a mustache php template file in directories and includes it (run as PHP).

Summary

Methods
Properties
Constants
__construct()
load()
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

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