Class Zend_Controller_Action_Helper_ViewRenderer

Description

View script integration

Zend_Controller_Action_Helper_ViewRenderer provides transparent view integration for action controllers. It allows you to create a view object once, and populate it throughout all actions. Several global options may be set:

  • noController: if set true, render() will not look for view scripts in subdirectories named after the controller
  • viewSuffix: what view script filename suffix to use
The helper autoinitializes the action controller view preDispatch(). It determines the path to the class file, and then determines the view base directory from there. It also uses the module name as a class prefix for helpers and views such that if your module name is 'Search', it will set the helper class prefix to 'Search_View_Helper' and the filter class prefix to ; 'Search_View_Filter'.

Usage:

  1.  // In your bootstrap:
  2.  
  3.  // In your action controller methods:
  4.  $viewHelper $this->_helper->getHelper('view');
  5.  
  6.  // Don't use controller subdirectories
  7.  $viewHelper->setNoController(true);
  8.  
  9.  // Specify a different script to render:
  10.  $this->_helper->viewRenderer('form');

Located in /Controller/Action/Helper/ViewRenderer.php (line 74)

Zend_Controller_Action_Helper_Abstract
   |
   --Zend_Controller_Action_Helper_ViewRenderer
Variable Summary
Method Summary
 void __construct ([ $view = null], [ $options = array()])
 void direct ([string $action = null], [string $name = null], [boolean $noController = null])
 string getModule ()
 string getModuleDirectory ()
 boolean getNeverController ()
 boolean getNeverRender ()
 boolean getNoController ()
 boolean getNoRender ()
 string getResponseSegment ()
 string getScriptAction ()
 string getViewScript ([string $action = null], [ $vars = array()])
 string getViewSuffix ()
 void init ()
 void initView ([string $path = null], [string $prefix = null], [ $options = array()])
 void postDispatch ()
 void render ([string $action = null], [string $name = null], [boolean $noController = null])
 void renderBySpec ([string $action = null], [ $vars = array()], [string $name = null])
 void renderScript (string $script, [string $name = null])
 Zend_Controller_Action_Helper_ViewRenderer setInflector ( $inflector, [boolean $reference = false])
 Zend_Controller_Action_Helper_ViewRenderer setRender ([string $action = null], [string $name = null], [boolean $noController = null])
 string _getBasePath ()
 string _getModuleDir ()
 void _setInflectorTarget (string $target)
 void _setModuleDir (string $dir)
 boolean _shouldRender ()
 string _translateSpec ([ $vars = array()])
 void __clone ()
Variables
Zend_View_Interface $view (line 79)
  • access: public
array $_delimiters (line 85)

Word delimiters

  • access: protected
Zend_Filter_Inflector $_inflector (line 90)
  • access: protected
string $_inflectorTarget = '' (line 96)

Inflector target

  • access: protected
string $_moduleDir = '' (line 102)

Current module directory

  • access: protected
boolean $_neverController = false (line 109)

Whether or not to autorender using controller name as subdirectory;

global setting (not reset at next invocation)

  • access: protected
boolean $_neverRender = false (line 116)

Whether or not to autorender postDispatch; global setting (not reset at

next invocation)

  • access: protected
boolean $_noController = false (line 122)

Whether or not to use a controller name as a subdirectory when rendering

  • access: protected
boolean $_noRender = false (line 129)

Whether or not to autorender postDispatch; per controller/action setting (reset

at next invocation)

  • access: protected
string|array $_pathDelimiters (line 135)

Characters representing path delimiters in the controller

  • access: protected
string $_responseSegment = null (line 141)

Which named segment of the response to utilize

  • access: protected
string $_scriptAction = null (line 147)

Which action view script to render

  • access: protected
string $_viewBasePathSpec = ':moduleDir/views' (line 153)

View object basePath

  • access: protected
string $_viewScriptPathNoControllerSpec = ':action.:suffix' (line 165)

View script path specification string, minus controller segment

  • access: protected
string $_viewScriptPathSpec = ':controller/:action.:suffix' (line 159)

View script path specification string

  • access: protected
string $_viewSuffix = 'phtml' (line 171)

View script suffix

  • access: protected

Inherited Variables

Inherited from Zend_Controller_Action_Helper_Abstract

Zend_Controller_Action_Helper_Abstract::$_actionController
Zend_Controller_Action_Helper_Abstract::$_frontController
Methods
Constructor __construct (line 182)

Constructor

Optionally set view object and options.

  • access: public
void __construct ([ $view = null], [ $options = array()])
direct (line 985)

Use this helper as a method; proxies to setRender()

  • access: public
void direct ([string $action = null], [string $name = null], [boolean $noController = null])
  • string $action
  • string $name
  • boolean $noController
getInflector (line 260)

Get inflector

  • access: public
Zend_Filter_Inflector getInflector ()
getModule (line 223)

Get current module name

  • access: public
string getModule ()
getModuleDirectory (line 240)

Get module directory

  • throws: Zend_Controller_Action_Exception
  • access: public
string getModuleDirectory ()
getNeverController (line 771)

Retrieve neverController flag value

  • access: public
boolean getNeverController ()
getNeverRender (line 656)

Retrieve neverRender flag value

  • access: public
boolean getNeverRender ()
getNoController (line 749)

Retrieve noController flag value

  • access: public
boolean getNoController ()
getNoRender (line 678)

Retrieve noRender flag value

  • access: public
boolean getNoRender ()
getResponseSegment (line 727)

Retrieve named response segment name

  • access: public
string getResponseSegment ()
getScriptAction (line 700)

Retrieve view script name

  • access: public
string getScriptAction ()
getViewBasePathSpec (line 542)

Retrieve the current view basePath specification string

  • access: public
string getViewBasePathSpec ()
getViewScript (line 617)

Get a view script based on an action and/or other variables

Uses values found in current request if no values passed in $vars.

If $_noController is set, uses $_viewScriptPathNoControllerSpec; otherwise, uses $_viewScriptPathSpec.

  • access: public
string getViewScript ([string $action = null], [ $vars = array()])
  • string $action
  • array $vars
getViewScriptPathNoControllerSpec (line 600)

Retrieve the current view script path specification string (no controller variant)

  • access: public
string getViewScriptPathNoControllerSpec ()
getViewScriptPathSpec (line 570)

Retrieve the current view script path specification string

  • access: public
string getViewScriptPathSpec ()
getViewSuffix (line 793)

Get view script suffix

  • access: public
string getViewSuffix ()
init (line 510)

init - initialize view

  • access: public
void init ()

Redefinition of:
Zend_Controller_Action_Helper_Abstract::init()
Hook into action controller initialization
initView (line 452)

Initialize the view object

$options may contain the following keys:

  • neverRender - flag dis/enabling postDispatch() autorender (affects all subsequent calls)
  • noController - flag indicating whether or not to look for view scripts in subdirectories named after the controller
  • noRender - flag indicating whether or not to autorender postDispatch()
  • responseSegment - which named response segment to render a view script to
  • scriptAction - what action script to render
  • viewBasePathSpec - specification to use for determining view base path
  • viewScriptPathSpec - specification to use for determining view script paths
  • viewScriptPathNoControllerSpec - specification to use for determining view script paths when noController flag is set
  • viewSuffix - what view script filename suffix to use

  • throws: Zend_Controller_Action_Exception
  • access: public
void initView ([string $path = null], [string $prefix = null], [ $options = array()])
  • string $path
  • string $prefix
  • array $options
postDispatch (line 954)

postDispatch - auto render a view

Only autorenders if:

  • _noRender is false
  • action controller is present
  • request has not been re-dispatched (i.e., _forward() has not been called)
  • response is not a redirect

  • access: public
void postDispatch ()

Redefinition of:
Zend_Controller_Action_Helper_Abstract::postDispatch()
Hook into action controller postDispatch() workflow
render (line 914)

Render a view based on path specifications

Renders a view based on the view script path specifications.

  • access: public
void render ([string $action = null], [string $name = null], [boolean $noController = null])
  • string $action
  • string $name
  • boolean $noController
renderBySpec (line 932)

Render a script based on specification variables

Pass an action, and one or more specification variables (view script suffix) to determine the view script path, and render that script.

  • access: public
void renderBySpec ([string $action = null], [ $vars = array()], [string $name = null])
  • string $action
  • array $vars
  • string $name
renderScript (line 890)

Render a view script (optionally to a named response segment)

Sets the noRender flag to true when called.

  • access: public
void renderScript (string $script, [string $name = null])
  • string $script
  • string $name
setInflector (line 299)

Set inflector

  • return: Provides a fluent interface
  • access: public
Zend_Controller_Action_Helper_ViewRenderer setInflector ( $inflector, [boolean $reference = false])
  • Zend_Filter_Inflector $inflector
  • boolean $reference: Whether the moduleDir, target, and suffix should be set as references to ViewRenderer properties
setNeverController (line 760)

Set the neverController flag (i.e., whether or not to render into controller subdirectories)

  • return: Provides a fluent interface
  • access: public
Zend_Controller_Action_Helper_ViewRenderer setNeverController ([boolean $flag = true])
  • boolean $flag
setNeverRender (line 645)

Set the neverRender flag (i.e., globally dis/enable autorendering)

  • return: Provides a fluent interface
  • access: public
Zend_Controller_Action_Helper_ViewRenderer setNeverRender ([boolean $flag = true])
  • boolean $flag
setNoController (line 738)

Set the noController flag (i.e., whether or not to render into controller subdirectories)

  • return: Provides a fluent interface
  • access: public
Zend_Controller_Action_Helper_ViewRenderer setNoController ([boolean $flag = true])
  • boolean $flag
setNoRender (line 667)

Set the noRender flag (i.e., whether or not to autorender)

  • return: Provides a fluent interface
  • access: public
Zend_Controller_Action_Helper_ViewRenderer setNoRender ([boolean $flag = true])
  • boolean $flag
setRender (line 806)

Set options for rendering a view script

  • return: Provides a fluent interface
  • access: public
Zend_Controller_Action_Helper_ViewRenderer setRender ([string $action = null], [string $name = null], [boolean $noController = null])
  • string $action: View script to render
  • string $name: Response named segment to render to
  • boolean $noController: Whether or not to render within a subdirectory named after the controller
setResponseSegment (line 711)

Set the response segment name

  • return: Provides a fluent interface
  • access: public
Zend_Controller_Action_Helper_ViewRenderer setResponseSegment (string $name)
  • string $name
setScriptAction (line 689)

Set the view script to use

  • return: Provides a fluent interface
  • access: public
Zend_Controller_Action_Helper_ViewRenderer setScriptAction (string $name)
  • string $name
setView (line 212)

Set the view object

  • return: Provides a fluent interface
  • access: public
setViewBasePathSpec (line 531)

Set view basePath specification

Specification can contain one or more of the following:

  • :moduleDir - current module directory
  • :controller - name of current controller in the request
  • :action - name of current action in the request
  • :module - name of current module in the request

  • return: Provides a fluent interface
  • access: public
Zend_Controller_Action_Helper_ViewRenderer setViewBasePathSpec (string $path)
  • string $path
setViewScriptPathNoControllerSpec (line 589)

Set view script path specification (no controller variant)

Specification can contain one or more of the following:

  • :moduleDir - current module directory
  • :controller - name of current controller in the request
  • :action - name of current action in the request
  • :module - name of current module in the request
:controller will likely be ignored in this variant.

  • return: Provides a fluent interface
  • access: public
Zend_Controller_Action_Helper_ViewRenderer setViewScriptPathNoControllerSpec (string $path)
  • string $path
setViewScriptPathSpec (line 559)

Set view script path specification

Specification can contain one or more of the following:

  • :moduleDir - current module directory
  • :controller - name of current controller in the request
  • :action - name of current action in the request
  • :module - name of current module in the request

  • return: Provides a fluent interface
  • access: public
Zend_Controller_Action_Helper_ViewRenderer setViewScriptPathSpec (string $path)
  • string $path
setViewSuffix (line 782)

Set view script suffix

  • return: Provides a fluent interface
  • access: public
Zend_Controller_Action_Helper_ViewRenderer setViewSuffix (string $suffix)
  • string $suffix
_generateDefaultPrefix (line 347)

Generate a class prefix for helper and filter classes

  • access: protected
string _generateDefaultPrefix ()
_getBasePath (line 375)

Retrieve base path based on location of current action controller

  • access: protected
string _getBasePath ()
_getModuleDir (line 337)

Get internal module directory representation

  • access: protected
string _getModuleDir ()
_setInflectorTarget (line 316)

Set inflector target

  • access: protected
void _setInflectorTarget (string $target)
  • string $target
_setModuleDir (line 327)

Set internal module directory representation

  • access: protected
void _setModuleDir (string $dir)
  • string $dir
_setOptions (line 403)

Set options

  • return: Provides a fluent interface
  • access: protected
  • array $options
_shouldRender (line 966)

Should the ViewRenderer render a view script?

  • access: protected
boolean _shouldRender ()
_translateSpec (line 836)

Inflect based on provided vars

Allowed variables are:

  • :moduleDir - current module directory
  • :module - current module name
  • :controller - current controller name
  • :action - current action name
  • :suffix - view script file suffix

  • access: protected
string _translateSpec ([ $vars = array()])
  • array $vars
__clone (line 198)

Clone - also make sure the view is cloned.

  • access: public
void __clone ()

Inherited Methods

Inherited From Zend_Controller_Action_Helper_Abstract

 Zend_Controller_Action_Helper_Abstract::getActionController()
 Zend_Controller_Action_Helper_Abstract::getFrontController()
 Zend_Controller_Action_Helper_Abstract::getName()
 Zend_Controller_Action_Helper_Abstract::getRequest()
 Zend_Controller_Action_Helper_Abstract::getResponse()
 Zend_Controller_Action_Helper_Abstract::init()
 Zend_Controller_Action_Helper_Abstract::postDispatch()
 Zend_Controller_Action_Helper_Abstract::preDispatch()
 Zend_Controller_Action_Helper_Abstract::setActionController()

Documentation generated on Mon, 21 Jun 2010 15:52:09 -0400 by phpDocumentor 1.4.3