Zend Framework  3.0
Public Member Functions | Public Attributes | Protected Member Functions | List of all members
DeclareVars Class Reference

Helper for declaring default values of template variables. More...

Public Member Functions

 __invoke ()
 Declare template vars to set default values and avoid notices when using strictVars.
 
- Public Member Functions inherited from AbstractHelper
 setView (Renderer $view)
 Set the View object.
 
 getView ()
 Get the view object.
 

Public Attributes

 $view
 

Protected Member Functions

 declareVar ($key, $value= '')
 Set a view variable.
 

Additional Inherited Members

- Protected Attributes inherited from AbstractHelper
 $view = null
 

Detailed Description

Helper for declaring default values of template variables.

Member Function Documentation

__invoke ( )

Declare template vars to set default values and avoid notices when using strictVars.

Primarily for use when using ::setStrictVars(), this helper can be used to declare template variables that may or may not already be set in the view object, as well as to set default values. Arrays passed as arguments to the method will be used to set default values; otherwise, if the variable does not exist, it is set to an empty string.

Usage: $this->declareVars( 'varName1', 'varName2', array('varName3' => 'defaultValue', 'varName4' => array() ) );

Parameters
string|arrayvariable number of arguments, all string names of variables to test
Returns
void
declareVar (   $key,
  $value = '' 
)
protected

Set a view variable.

Checks to see if a $key is set in the view object; if not, sets it to $value.

Parameters
string$key
string$valueDefaults to an empty string
Returns
void

Member Data Documentation

$view