View/Abstract.php
Zend Framework
LICENSE
This source file is subject to the new BSD license that is bundled
with this package in the file LICENSE.txt.
It is also available through the world-wide-web at this URL:
http://framework.zend.com/license/new-bsd
If you did not receive a copy of the license and are unable to
obtain it through the world-wide-web, please send an email
to license@zend.com so we can send you a copy immediately.
- Category
- Zend
- Copyright
- Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
- Package
- Zend_View
- Version
- $Id$
Package: Zend_ViewAbstract class for Zend_View to help enforce private constructs.
- Implements
- Children
- \Zend_View
- Category
- Zend
- Copyright
- Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
Properties
Methods
__call(string $name, array $args) : string
Accesses a helper object from within a script.
If the helper class has a 'view' property, sets it with the current view
object.
ParametersName | Type | Description |
---|
$name | string | The helper name. |
---|
$args | array | The parameters for the helper. |
---|
ReturnsType | Description |
---|
string | The result of the helper output. |
__construct(array $config = array()) : void
ParametersName | Type | Description |
---|
$config | array | Configuration key-value pairs. |
---|
__get(string $key) : null
Prevent E_NOTICE for nonexistent values
If {@link strictVars()} is on, raises a notice.
ParametersName | Type | Description |
---|
$key | string | |
---|
Returns__isset(string $key) : boolean
Allows testing with empty() and isset() to work inside
templates.
ParametersName | Type | Description |
---|
$key | string | |
---|
Returns __set(string $key, mixed $val) : void
Directly assigns a variable to the view script.
Checks first to ensure that the caller is not attempting to set a
protected or private member (by checking for a prefixed underscore); if
not, the public member is set; otherwise, an exception is raised.
ParametersName | Type | Description |
---|
$key | string | The variable name. |
---|
$val | mixed | The variable value. |
---|
ThrowsException | Description |
---|
\Zend_View_Exception | if an attempt to set a private or protected
member is detected |
__unset(string $key) : void
Allows unset() on object properties to work
ParametersName | Type | Description |
---|
$key | string | |
---|
_addPath(string $type, string | array $path, string $prefix = null) : void
Adds paths to the path stack in LIFO order.
Zend_View::_addPath($type, 'dirname') adds one directory
to the path stack.
Zend_View::_addPath($type, $array) adds one directory for
each array element value.
In the case of filter and helper paths, $prefix should be used to
specify what class prefix to use with the given path.
ParametersName | Type | Description |
---|
$type | string | The path type ('script', 'helper', or 'filter'). |
---|
$path | string | array | The path specification. |
---|
$prefix | string | Class prefix to use with path (helpers and filters
only) |
---|
_addPluginPath(string $type, string $classPrefix, array $paths) : \Zend_View_Abstract
Add a prefixPath for a plugin type
ParametersName | Type | Description |
---|
$type | string | |
---|
$classPrefix | string | |
---|
$paths | array | |
---|
Returns _filter(string $buffer) : string
Applies the filter callback to a buffer.
ParametersName | Type | Description |
---|
$buffer | string | The buffer contents. |
---|
ReturnsType | Description |
---|
string | The filtered buffer. |
_getPaths(string $type) : array
Return all paths for a given path type
ParametersName | Type | Description |
---|
$type | string | The path type ('helper', 'filter', 'script') |
---|
Returns _getPluginPath(string $type, string $name) : string | false
Get a path to a given plugin class of a given type
ParametersName | Type | Description |
---|
$type | string | |
---|
$name | string | |
---|
ReturnsType | Description |
---|
string | false | |
_script(string $name) : void
Finds a view script from the available directories.
ParametersName | Type | Description |
---|
$name | string | The base name of the script. |
---|
_setFilterClass(string $name, string $class, string $file) : void
Register filter class as loaded
ParametersName | Type | Description |
---|
$name | string | |
---|
$class | string | |
---|
$file | string | path to class file |
---|
_setHelperClass(string $name, string $class, string $file) : void
Register helper class as loaded
ParametersName | Type | Description |
---|
$name | string | |
---|
$class | string | |
---|
$file | string | path to class file |
---|
_setPath(string $type, string | array $path, string $classPrefix = null) : void
Resets the path stack for helpers and filters.
ParametersName | Type | Description |
---|
$type | string | The path type ('helper' or 'filter'). |
---|
$path | string | array | The directory (-ies) to set as the path. |
---|
$classPrefix | string | Class prefix to apply to elements of $path |
---|
addBasePath(string $path, $classPrefix = 'Zend_View') : \Zend_View_Abstract
Given a base path, add script, helper, and filter paths relative to it
Assumes a directory structure of:
basePath/
scripts/
helpers/
filters/
ParametersName | Type | Description |
---|
$path | string | |
---|
$classPrefix | | |
---|
ReturnsaddFilterPath( $path, string $classPrefix = 'Zend_View_Filter_') : \Zend_View_Abstract
Adds to the stack of filter paths in LIFO order.
ParametersName | Type | Description |
---|
$path | | |
---|
$classPrefix | string | Class prefix to use with classes in this
directory; defaults to Zend_View_Filter |
---|
Returns addHelperPath( $path, string $classPrefix = 'Zend_View_Helper_') : \Zend_View_Abstract
Adds to the stack of helper paths in LIFO order.
ParametersName | Type | Description |
---|
$path | | |
---|
$classPrefix | string | Class prefix to use with classes in this
directory; defaults to Zend_View_Helper |
---|
Returns assign( $spec, $value = null) : \Zend_View_Abstract
Assigns variables to the view script via differing strategies.
Zend_View::assign('name', $value) assigns a variable called 'name'
with the corresponding $value.
Zend_View::assign($array) assigns the array keys as variable
names (with the corresponding array values).
ParametersName | Type | Description |
---|
$spec | | |
---|
$value | | |
---|
ReturnsThrowsException | Description |
---|
\Zend_View_Exception | if $spec is neither a string nor an array,
or if an attempt to set a private or protected member is detected |
Details- See
-
clearVars() : void
Clear all assigned variables
Clears all variables assigned to Zend_View either via {@link assign()} or
property overloading ({@link __set()}).
escape(mixed $var) : mixed
Escapes a value for output in a view script.
If escaping mechanism is one of htmlspecialchars or htmlentities, uses
{@link $_encoding} setting.
ParametersName | Type | Description |
---|
$var | mixed | The output to escape. |
---|
ReturnsType | Description |
---|
mixed | The escaped value. |
getEngine() : \Zend_View_Abstract
Return the template engine object
Returns the object instance, as it is its own template engine
ReturnsgetFilter(string $name) : object
Get a filter object by name
ParametersName | Type | Description |
---|
$name | string | |
---|
Returns getFilterPath(string $name) : string | false
Get full path to a filter class file specified by $name
ParametersName | Type | Description |
---|
$name | string | |
---|
ReturnsType | Description |
---|
string | false | False on failure, path on success |
getFilters() : array
Return array of all currently active filters
Only returns those that have already been instantiated.
ReturnsgetHelperPath(string $name) : string | false
Get full path to a helper class file specified by $name
ParametersName | Type | Description |
---|
$name | string | |
---|
ReturnsType | Description |
---|
string | false | False on failure, path on success |
getHelpers() : array
Get array of all active helpers
Only returns those that have already been instantiated.
ReturnsgetPluginLoader(string $type) : \Zend_Loader_PluginLoader
Retrieve plugin loader for a specific plugin type
ParametersName | Type | Description |
---|
$type | string | |
---|
Returns getScriptPath(string $name) : false | string
Return full path to a view script specified by $name
ParametersName | Type | Description |
---|
$name | string | |
---|
ReturnsType | Description |
---|
false | string | False if script not found |
Throws getVars() : array
Return list of all assigned variables
Returns all public properties of the object. Reflection is not used
here as testing reflection properties for visibility is buggy.
Returnsinit() : void
Allow custom object initialization when extending Zend_View_Abstract or
Zend_View
Triggered by {@link __construct() the constructor} as its final action.
render(string $name) : string
Processes a view script and returns the output.
ParametersName | Type | Description |
---|
$name | string | The script name to process. |
---|
ReturnsType | Description |
---|
string | The script output. |
setBasePath(string $path, $classPrefix = 'Zend_View') : \Zend_View_Abstract
Given a base path, sets the script, helper, and filter paths relative to it
Assumes a directory structure of:
basePath/
scripts/
helpers/
filters/
ParametersName | Type | Description |
---|
$path | string | |
---|
$classPrefix | | |
---|
ReturnssetEncoding(string $encoding) : \Zend_View_Abstract
Set encoding to use with htmlentities() and htmlspecialchars()
ParametersName | Type | Description |
---|
$encoding | string | |
---|
Returns setEscape(mixed $spec) : \Zend_View_Abstract
Sets the _escape() callback.
ParametersName | Type | Description |
---|
$spec | mixed | The callback for _escape() to use. |
---|
Returns setFilterPath( $path, string $classPrefix = 'Zend_View_Filter_') : \Zend_View_Abstract
Resets the stack of filter paths.
To clear all paths, use Zend_View::setFilterPath(null).
ParametersName | Type | Description |
---|
$path | | |
---|
$classPrefix | string | The class prefix to apply to all elements in
$path; defaults to Zend_View_Filter |
---|
ReturnssetHelperPath(string | array $path, string $classPrefix = 'Zend_View_Helper_') : \Zend_View_Abstract
Resets the stack of helper paths.
To clear all paths, use Zend_View::setHelperPath(null).
ParametersName | Type | Description |
---|
$path | string | array | The directory (-ies) to set as the path. |
---|
$classPrefix | string | The class prefix to apply to all elements in
$path; defaults to Zend_View_Helper |
---|
ReturnssetScriptPath( $path) : \Zend_View_Abstract
Resets the stack of view script paths.
To clear all paths, use Zend_View::setScriptPath(null).
ParametersReturnsstrictVars(boolean $flag = true) : \Zend_View_Abstract
Enable or disable strict vars
If strict variables are enabled, {@link __get()} will raise a notice
when a variable is not defined.
Use in conjunction with {@link Zend_View_Helper_DeclareVars the declareVars() helper}
to enforce strict variable handling in your view scripts.
ParametersName | Type | Description |
---|
$flag | boolean | |
---|
Returns