PHP Class Goetas\Twital\TwitalLoader

Compiles a Twital template into a Twig template.
Author: Asmir Mustafic ([email protected])
Inheritance: implements Twig_LoaderInterface, implements Twig_ExistsLoaderInterface
Datei anzeigen Open project: goetas/twital Class Usage Examples

Protected Properties

Property Type Description
$loader Twig_LoaderInterface The wrapped Twig loader
$sourceAdapters array Items are strings or callbacks
$twital Twital The internal Twital compiler

Public Methods

Method Description
__construct ( Twig_LoaderInterface $loader = null, Twital $twital = null, boolean $addDefaults = true ) Creates a new Twital loader.
addSourceAdapter ( string | callback $pattern, Goetas\Twital\SourceAdapter $adapter ) : TwitalLoader Add a new pattern that can decide if a template is twital-compilable or not.
exists ( $name )
getCacheKey ( $name )
getLoader ( ) : Twig_LoaderInterface Get the wrapped Twig loader
getSource ( $name )
getSourceAdapter ( string $name ) : Goetas\Twital\SourceAdapter Decide if a template is twital-compilable or not.
getSourceAdapters ( ) : array: Get all patterns used to choose if a template is twital-compilable or not
getTwital ( ) : Twital
isFresh ( $name, $time )
setLoader ( Twig_LoaderInterface $loader ) : TwitalLoader Set the wrapped Twig loader

Method Details

__construct() public method

Creates a new Twital loader.
public __construct ( Twig_LoaderInterface $loader = null, Twital $twital = null, boolean $addDefaults = true )
$loader Twig_LoaderInterface
$twital Twital
$addDefaults boolean If NULL, some standard rules will be used (`*.twital.*` and `*.twital`).

addSourceAdapter() public method

If $pattern is a string, then must be a valid regex that matches the template filename. If $pattern is a callback, then must return true if the template is compilable, false otherwise.
public addSourceAdapter ( string | callback $pattern, Goetas\Twital\SourceAdapter $adapter ) : TwitalLoader
$pattern string | callback
$adapter Goetas\Twital\SourceAdapter
return TwitalLoader

exists() public method

public exists ( $name )

getCacheKey() public method

public getCacheKey ( $name )

getLoader() public method

Get the wrapped Twig loader
public getLoader ( ) : Twig_LoaderInterface
return Twig_LoaderInterface

getSource() public method

public getSource ( $name )

getSourceAdapter() public method

Decide if a template is twital-compilable or not.
public getSourceAdapter ( string $name ) : Goetas\Twital\SourceAdapter
$name string
return Goetas\Twital\SourceAdapter

getSourceAdapters() public method

Get all patterns used to choose if a template is twital-compilable or not
public getSourceAdapters ( ) : array:
return array:

getTwital() public method

public getTwital ( ) : Twital
return Twital

isFresh() public method

public isFresh ( $name, $time )

setLoader() public method

Set the wrapped Twig loader
public setLoader ( Twig_LoaderInterface $loader ) : TwitalLoader
$loader Twig_LoaderInterface
return TwitalLoader

Property Details

$loader protected_oe property

The wrapped Twig loader
protected Twig_LoaderInterface $loader
return Twig_LoaderInterface

$sourceAdapters protected_oe property

Items are strings or callbacks
protected array $sourceAdapters
return array

$twital protected_oe property

The internal Twital compiler
protected Twital,Goetas\Twital $twital
return Twital