\SiteTreeReflectionTemplate
A {@link ReflectionTemplate} class designed for working with SiteTree templates. Populates the commmon template accessors with known SiteTree/ContentController methods.
- Author: Uncle Cheese <unclecheese@leftandmain.com>
Synopsis
class SiteTreeReflectionTemplate
extends ReflectionTemplate
{
- // Inherited members from ReflectionTemplate
- protected $templateAccessors;
- protected $dbfieldFunctions;
- protected $listFunctions;
- protected $code;
- protected array $blockManifest;
- protected ReflectionTemplate_Block $topBlock;
- // methods
- public array getTemplateAccessors()
- // Inherited methods from ReflectionTemplate
- public array getTemplateAccessors()
- public array getDBFieldFunctions()
- public array getListFunctions()
- public string inferDatatype()
- public void process()
- public ReflectionTemplate_Block getBlockByID()
- public ReflectionTemplate_Block getBlockByName()
- public array getBlocks()
- public array getLoops()
- public array getWiths()
- public array getTopLevelVars()
- public array getTopLevelBlocks()
- public array getTopLevelBooleans()
- public string getCode()
Hierarchy
Extends
Tasks
Line | Task |
---|---|
109+ | This gets really ugly with some hardcoded opinions. Needs rethinking. |
Members
protected
- $blockManifest
—
array
The list of blocks in the template, indexed by their strpos - $code
—
string
The code being analysed - $dbfieldFunctions
—
array
A computed list of all the functions available to {@link DBField} classes - $listFunctions
—
array
A computed list of all the functions available to {@link SS_List} instances - $templateAccessors
—
array
A computed list of all the core template accessors, e.g. $Up, $Top - $topBlock
—
ReflectionTemplate_Block
A reference to the $Top block
Methods
public
- getTemplateAccessors() — Gets all the core template accessors available to SiteTree templates and caches the result
Inherited from ReflectionTemplate
public
- getBlockByID() — Gets a block by its identifier, or offset, in the template string
- getBlockByName() — Gets a block by its name, e.g. <% loop $Items %> is named "Items" Not very reliable, as there may be multiple blocks with the same name.
- getBlocks() — Gets all the blocks in the template, including those that are nested
- getCode() — Gets the code being analysed
- getDBFieldFunctions() — Gets all methods that are defined on {@link DBField} instances and caches the result
- getListFunctions() — Gets all the methods available to {@link SS_List} instances and caches the result.
- getLoops() — Gets all the blocks that are <% loop %>
- getTemplateAccessors() — Gets all the template accessors, looking at the {@link TemplateGlobalProvider} implementors and caches the result.
- getTopLevelBlocks() — Gets all the blocks at the top level
- getTopLevelBooleans() — Gets all the possible boolean variables at the top level, e.g. <% if $Foo %>
- getTopLevelVars() — Gets all the variables at the top level, mapped as $VariableName => $FieldType
- getWiths() — Gets all the blocks that are <% with %>
- inferDatatype() — Given a variable name, figure out what type it might be. This can be guided via the {@link Config} layer
- process() — Does all the heavy lifting of processing the template, getting all the vars and indexing the blocks by their strpos(), and assigning their contents to {@link ReflectionTemplate_Block} instances.