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.  Zend_Controller_Action_HelperBroker::addHelper(new Wopnet_Controller_Action_Helper_Abstract());
  3.  
  4.  // In your action controller methods:
  5.  $viewHelper $this->_helper->getHelper('view');
  6.  
  7.  // Don't use controller subdirectories
  8.  $viewHelper->setNoController(true);
  9.  
  10.  // Specify a different script to render:
  11.  $this->_helper->view('form');

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

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])
 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 setRender ([string $action = null], [string $name = null], [boolean $noController = null])
 string _getBasePath ()
 string _translateSpec (string $spec, [ $vars = array()])
Variables
Zend_View_Interface $view (line 76)
  • access: public
array $_delimiters (line 82)

Word delimiters

  • access: protected
Zend_Controller_Front $_frontController (line 88)

Front controller instance

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

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

next invocation)

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

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

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

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

at next invocation)

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

Which named segment of the response to utilize

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

Which action view script to render

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

View object basePath

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

View script path specification string, minus controller segment

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

View script path specification string

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

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::$_request
Zend_Controller_Action_Helper_Abstract::$_response
Methods
Constructor __construct (line 155)

Constructor

Optionally set view object and options.

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

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
getFrontController (line 183)

Retrieve front controller instance

  • access: public
Zend_Controller_Front getFrontController ()
getNeverRender (line 474)

Retrieve neverRender flag value

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

Retrieve noController flag value

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

Retrieve noRender flag value

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

Retrieve named response segment name

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

Retrieve view script name

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

Retrieve the current view basePath specification string

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

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 420)

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

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

Retrieve the current view script path specification string

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

Get view script suffix

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

init - initialize view

  • access: public
void init ()

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

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

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

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 719)

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 737)

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 695)

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
setNeverRender (line 463)

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

  • access: public
Zend_Controller_Action_Helper_ViewRenderer setNeverRender ([boolean $flag = true])
  • boolean $flag
setNoController (line 556)

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

  • access: public
Zend_Controller_Action_Helper_ViewRenderer setNoController ([boolean $flag = true])
  • boolean $flag
setNoRender (line 485)

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

  • access: public
Zend_Controller_Action_Helper_ViewRenderer setNoRender ([boolean $flag = true])
  • boolean $flag
setRender (line 602)

Set options for rendering a view script

  • 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 529)

Set the response segment name

  • access: public
Zend_Controller_Action_Helper_ViewRenderer setResponseSegment (string $name)
  • string $name
setScriptAction (line 507)

Set the view script to use

  • access: public
Zend_Controller_Action_Helper_ViewRenderer setScriptAction (string $name)
  • string $name
setView (line 172)

Set the view object

  • access: public
setViewBasePathSpec (line 351)

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

  • access: public
Zend_Controller_Action_Helper_ViewRenderer setViewBasePathSpec (string $path)
  • string $path
setViewScriptPathNoControllerSpec (line 409)

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.

  • access: public
Zend_Controller_Action_Helper_ViewRenderer setViewScriptPathNoControllerSpec (string $path)
  • string $path
setViewScriptPathSpec (line 379)

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

  • access: public
Zend_Controller_Action_Helper_ViewRenderer setViewScriptPathSpec (string $path)
  • string $path
setViewSuffix (line 578)

Set view script suffix

  • access: public
Zend_Controller_Action_Helper_ViewRenderer setViewSuffix (string $suffix)
  • string $suffix
_generateDefaultPrefix (line 197)

Generate a class prefix for helper and filter classes

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

Retrieve base path based on location of current action controller

  • access: protected
string _getBasePath ()
_setOptions (line 230)

Set options

  • access: protected
  • array $options
_translateSpec (line 633)

Inject values into a spec string

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 (string $spec, [ $vars = array()])
  • string $spec
  • array $vars

Inherited Methods

Inherited From Zend_Controller_Action_Helper_Abstract

 Zend_Controller_Action_Helper_Abstract::getActionController()
 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 Sun, 27 May 2007 23:28:27 -0700 by phpDocumentor 1.3.2