Abstract Class Twig_Template

InheritanceTwig_Template
ImplementsTwig_TemplateInterface

Default base class for compiled templates.

Public Methods

Hide inherited methods

MethodDescriptionDefined By
__construct() Constructor. Twig_Template
display() {@inheritdoc} Twig_Template
displayBlock() Displays a block. Twig_Template
displayParentBlock() Displays a parent block. Twig_Template
getBlockNames() Returns all block names. Twig_Template
getBlocks() Returns all blocks. Twig_Template
getDebugInfo() Returns debug information about the template. Twig_Template
getEnvironment() Twig_Template
getParent() Returns the parent template. Twig_Template
getSource() Returns the template source code. Twig_Template
getTemplateName() Returns the template name. Twig_Template
hasBlock() Returns whether a block exists or not. Twig_Template
isTraitable() Twig_Template
render() {@inheritdoc} Twig_Template
renderBlock() Renders a block. Twig_Template
renderParentBlock() Renders a parent block. Twig_Template

Protected Methods

Hide inherited methods

MethodDescriptionDefined By
displayWithErrorHandling() Twig_Template
doDisplay() Auto-generated method to display the template with the given context. Twig_Template
doGetParent() Twig_Template
getAttribute() Returns the attribute value for a given array/object. Twig_Template
getContext() Returns a variable from the context. Twig_Template
loadTemplate() Twig_Template

Property Details

$blocks protected property
protected $blocks = []
$cache protected static property
protected static $cache = []
$env protected property
protected $env null
$parent protected property
protected $parent null
$parents protected property
protected $parents = []
$traits protected property
protected $traits = []

Method Details

__construct() public method

Constructor.

public void __construct ( Twig_Environment $env )
$env Twig_Environment

A Twig_Environment instance

display() public method

{@inheritdoc}

public void display ( array $context, array $blocks = [] )
$context
$blocks
displayBlock() public method

Displays a block.

This method is for internal use only and should never be called directly.

public void displayBlock ( $name, array $context, array $blocks = [], $useBlocks true )
$name string

The block name to display

$context array

The context

$blocks array

The current set of blocks

$useBlocks bool

Whether to use the current set of blocks

displayParentBlock() public method

Displays a parent block.

This method is for internal use only and should never be called directly.

public void displayParentBlock ( $name, array $context, array $blocks = [] )
$name string

The block name to display from the parent

$context array

The context

$blocks array

The current set of blocks

displayWithErrorHandling() protected method

protected void displayWithErrorHandling ( array $context, array $blocks = [] )
$context
$blocks
doDisplay() protected abstract method

Auto-generated method to display the template with the given context.

protected abstract void doDisplay ( array $context, array $blocks = [] )
$context array

An array of parameters to pass to the template

$blocks array

An array of blocks to pass to the template

doGetParent() protected method

protected void doGetParent ( array $context )
$context
getAttribute() protected method

Returns the attribute value for a given array/object.

protected mixed getAttribute ( $object, $item, array $arguments = [], $type self::ANY_CALL, $isDefinedTest false, $ignoreStrictCheck false )
$object mixed

The object or array from where to get the item

$item mixed

The item to get from the array or object

$arguments array

An array of arguments to pass if the item is an object method

$type string

The type of attribute (@see Twig_Template constants)

$isDefinedTest bool

Whether this is only a defined check

$ignoreStrictCheck bool

Whether to ignore the strict attribute check or not

return mixed

The attribute value, or a Boolean when $isDefinedTest is true, or null when the attribute is not set and $ignoreStrictCheck is true

throws Twig_Error_Runtime

if the attribute does not exist and Twig is running in strict mode and $isDefinedTest is false

getBlockNames() public method

Returns all block names.

This method is for internal use only and should never be called directly.

See also hasBlock().

public array getBlockNames ( )
return array

An array of block names

getBlocks() public method

Returns all blocks.

This method is for internal use only and should never be called directly.

See also hasBlock().

public array getBlocks ( )
return array

An array of blocks

getContext() protected method

Returns a variable from the context.

This method is for internal use only and should never be called directly.

This method should not be overridden in a sub-class as this is an implementation detail that has been introduced to optimize variable access for versions of PHP before 5.4. This is not a way to override the way to get a variable value.

protected mixed getContext ( $context, $item, $ignoreStrictCheck false )
$context array

The context

$item string

The variable to return from the context

$ignoreStrictCheck bool

Whether to ignore the strict variable check or not

return mixed

The content of the context variable

throws Twig_Error_Runtime

if the variable does not exist and Twig is running in strict mode

getDebugInfo() public abstract method

Returns debug information about the template.

public abstract array getDebugInfo ( )
return array

Debug information

getEnvironment() public method

public void getEnvironment ( )
getParent() public method

Returns the parent template.

This method is for internal use only and should never be called directly.

public Twig_TemplateInterface|false getParent ( array $context )
$context array
return Twig_TemplateInterface|false

The parent template or false if there is no parent

getSource() public method

Returns the template source code.

public string getSource ( )
return string

The template source code

getTemplateName() public abstract method

Returns the template name.

public abstract string getTemplateName ( )
return string

The template name

hasBlock() public method

Returns whether a block exists or not.

This method is for internal use only and should never be called directly.

This method does only return blocks defined in the current template or defined in "used" traits.

It does not return blocks from parent templates as the parent template name can be dynamic, which is only known based on the current context.

public bool hasBlock ( $name )
$name string

The block name

return bool

True if the block exists, false otherwise

isTraitable() public method

public void isTraitable ( )
loadTemplate() protected method

protected void loadTemplate ( $template, $templateName null, $line null, $index null )
$template
$templateName
$line
$index
render() public method

{@inheritdoc}

public void render ( array $context )
$context
renderBlock() public method

Renders a block.

This method is for internal use only and should never be called directly.

public string renderBlock ( $name, array $context, array $blocks = [], $useBlocks true )
$name string

The block name to render

$context array

The context

$blocks array

The current set of blocks

$useBlocks bool

Whether to use the current set of blocks

return string

The rendered block

renderParentBlock() public method

Renders a parent block.

This method is for internal use only and should never be called directly.

public string renderParentBlock ( $name, array $context, array $blocks = [] )
$name string

The block name to render from the parent

$context array

The context

$blocks array

The current set of blocks

return string

The rendered block