\Horde_View_Base

Abstract base class for Horde_View to get private constructs out of template scope.

Summary

Methods
Properties
Constants
__construct()
__get()
__call()
addTemplatePath()
setTemplatePath()
getTemplatePaths()
addHelper()
assign()
render()
renderPartial()
setEncoding()
getEncoding()
throwOnHelperCollision()
$defaultFormBuilder
No constants found
_template()
_run()
No protected properties found
N/A
No private methods found
$_templatePath
$_file
$_helpers
$_encoding
$_throwOnHelperCollision
$_protectedProperties
N/A

Properties

$defaultFormBuilder

$defaultFormBuilder : string

Type

string

$_templatePath

$_templatePath : array

Path stack for templates.

Type

array

$_file

$_file : string

Template to execute.

Stored in a private variable to keep it out of the public view scope.

Type

string

$_helpers

$_helpers : array

Cache of helper objects.

Type

array

$_encoding

$_encoding : string

Encoding to use in escaping mechanisms.

Type

string

$_throwOnHelperCollision

$_throwOnHelperCollision : boolean

Should we throw an error if helper methods collide?

Type

boolean

$_protectedProperties

$_protectedProperties : array

Protected properties.

Type

array

Methods

__construct()

__construct(array  $config = array()) 

Constructor.

Parameters

array $config

Configuration key-value pairs.

__get()

__get(  $name) : null

Undefined variables return null.

Parameters

$name

Returns

null

__call()

__call(string  $method, array  $args) : string

Accesses a helper object from within a template.

Parameters

string $method

The helper method.

array $args

The parameters for the helper.

Throws

\Horde_View_Exception

Returns

string —

The result of the helper method.

addTemplatePath()

addTemplatePath(  $path) 

Adds to the stack of template paths in LIFO order.

Parameters

$path

setTemplatePath()

setTemplatePath(  $path) 

Resets the stack of template paths.

To clear all paths, use Horde_View::setTemplatePath(null).

Parameters

$path

getTemplatePaths()

getTemplatePaths() : array

Returns the template paths.

Returns

array —

The stack of current template paths.

addHelper()

addHelper(\Horde_View_Helper|string  $helper) : \Horde_View_Helper

Adds to the stack of helpers in LIFO order.

If the $helper parameter is a string instead of a Helper instance, then it will be treated as a class name. Names without "_" and that do not have "Helper" in them will be prefixed with Horde_ViewHelper; other names will be treated as literal class names. Examples:

// Adds a new Horde_View_Helper_Tag to the view: $v->addHelper('Tag'); // Adds a new AppHelper object to the view if it exists, otherwise // throws an exception: $v->addHelper('AppHelper');

Parameters

\Horde_View_Helper|string $helper

The helper instance to add.

Throws

\Horde_View_Exception

Returns

\Horde_View_Helper —

Returns the helper object that was added.

assign()

assign(array  $array) 

Assigns multiple variables to the view.

The array keys are used as names, each assigned their corresponding array value.

Parameters

array $array

The array of key/value pairs to assign.

render()

render(string  $name,   $locals = array()) : string

Processes a template and returns the output.

Parameters

string $name

The template to process.

$locals

Returns

string —

The template output.

renderPartial()

renderPartial(string  $name, array  $options = array()) : string

Renders a partial template.

Partial template filenames are named with a leading underscore, although this underscore is not used when specifying the name of the partial.

We would reference the file /views/shared/_sidebarInfo.html in our template using:

renderPartial('sidebarInfo') ?>

Parameters

string $name
array $options

Returns

string —

The template output.

setEncoding()

setEncoding(string  $encoding) 

Sets the output encoding.

Parameters

string $encoding

A character set name.

getEncoding()

getEncoding() : string

Returns the current output encoding.

Returns

string —

The current character set.

throwOnHelperCollision()

throwOnHelperCollision(boolean  $throw = true) 

Controls the behavior when a helper method is overridden by another helper.

Parameters

boolean $throw

Throw an exception when helper methods collide?

_template()

_template(  $name) : string

Finds a template from the available directories.

Parameters

$name

string The base name of the template.

Returns

string —

The full path to the first matching template.

_run()

_run() 

Includes the template in a scope with only public variables.