Template

Template object factory. Normally the template configs and object names are defined in the app config array or ini file, "$object-name = Template::get('object-name');" will return the template engine object on demand. Note that when your factories inherit the "Response" class you wont need direct access to the template objects as the "Response" class will efficiently create and use the template engine objects.
Source
Template.php
Implements
IObjectFactory
Depends on
Arta , PHPTAL , PHPTAL_GetTextTranslator , Smarty , TemplateEngineNotSupported
Since
1.0.0

Static Methods

config

array|string Template::config(
    string objectName=null,
    string index=null,
    array configs=null
)

Set or get configs for a template access object. The configs will only be set if a last param is passed. The configs are stored in "Arta::$tplConfigs" which also contains the app template object configs (from the app config ini file or array).

Arguments

    objectName=null (string)
    The object name to set or to get configs for, null=return all object configs
    index=null (string)
    Config key, to get the value of a specific setting
    configs=null (array)
    To add a new template object configs
    {
        string engine         : template engine name e.g. smarty or phptal,
        string engine_path    : path to template engine libraries,
        string templates_path :
            path to the directory which templates will be put into,
        string factory_path   :
            path to directory containing the app's factory classes,
        string factory_config : path to the URL/factory mapping file,
        string syntax         : template syntax: XHTML or HTML5 or XML,
    }
    

Returns

array|string
{configs} or {object-name: {configs},} or the value of a config key

get

object|array Template::get(string | bool objectName=null, bool remove=false)

Creates and returns or returns an already created object. When creating a new object the object configs are expected to exists in "Arta::$tplConfigs", note that the template objects defined in the app config array or ini file are put in "Arta::$tplConfigs" by Artaengine.
Get a template access object by passing the object name.
Get all template access objects in an array by passing true.
To remove an object pass true for the second argument.

Arguments

    objectName=null (string | bool)
    Object name to create or to get handle of, null=return the last object in the list, true=return all objects
    remove=false (bool)
    true=remove/unsset the object

Returns

object|array
Reference to a template engine object or a list of template engine objects

Throws

getCreateNew

Object Template::getCreateNew(string objectName, array configs)

Creates and returns an object. Use this method to create a new object by passing the object configs versus "get()" that expects the configs to exist in "Arta::$tplConfigs".

Arguments

    objectName (string)
    The object name to be created
    configs (array)
    Template object configs
    {
        string engine         : template engine name e.g. smarty or phptal,
        string engine_path    : path to template engine libraries,
        string templates_path :
            path to the directory which templates will be put into,
        string factory_path   :
            path to directory containing the app's factory classes,
        string factory_config : path to the URL/factory mapping file,
        string syntax         : template syntax: XHTML or HTML5 or XML,
    }
    

Returns

Object
Reference to the newly created tamplate object

Throws

remove

void Template::remove(string objectName)

Remove an object if already been created.

Arguments

    objectName (string)
    Object name to remove

Returns

void