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.
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:
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:
// In your bootstrap:
Zend_Controller_Action_HelperBroker::addHelper(new Zend_Controller_Action_Helper_ViewRenderer());
// In your action controller methods: $viewHelper = $this->_helper->getHelper('view');
// Don't use controller subdirectories $viewHelper->setNoController(true);
// Specify a different script to render: $this->_helper->viewRenderer('form');
array $_delimiters = ''Word delimiters
DetailsZend_Filter_Inflector $_inflector = ''
Detailsstring $_inflectorTarget = ''Inflector target
Detailsstring $_moduleDir = ''Current module directory
Detailsboolean $_neverController = 'false'Whether or not to autorender using controller name as subdirectory; global setting (not reset at next invocation)
Detailsboolean $_neverRender = 'false'Whether or not to autorender postDispatch; global setting (not reset at next invocation)
Detailsboolean $_noController = 'false'Whether or not to use a controller name as a subdirectory when rendering
Detailsboolean $_noRender = 'false'Whether or not to autorender postDispatch; per controller/action setting (reset at next invocation)
Detailsstring|array $_pathDelimiters = ''Characters representing path delimiters in the controller
Detailsstring $_responseSegment = 'null'Which named segment of the response to utilize
Detailsstring $_scriptAction = 'null'Which action view script to render
Detailsstring $_viewBasePathSpec = ':moduleDir/views'View object basePath
Detailsstring $_viewScriptPathNoControllerSpec = ':action.:suffix'View script path specification string, minus controller segment
Detailsstring $_viewScriptPathSpec = ':controller/:action.:suffix'View script path specification string
Detailsstring $_viewSuffix = 'phtml'View script suffix
DetailsZend_View_Interface $view = ''
Details__clone(
)
:
voidClone - also make sure the view is cloned.
Details__construct(
Zend_View_Interface $view
=
null, array $options
=
array
)
:
voidConstructor
Optionally set view object and options.
Details_generateDefaultPrefix(
)
:
stringGenerate a class prefix for helper and filter classes
Details_getBasePath(
)
:
stringRetrieve base path based on location of current action controller
Details_getModuleDir(
)
:
stringGet internal module directory representation
Details_setInflectorTarget(
string $target
)
:
voidSet inflector target
Details_setModuleDir(
string $dir
)
:
voidSet internal module directory representation
Details_setOptions(
array $options
)
:
Zend_Controller_Action_Helper_ViewRendererSet options
Details_shouldRender(
)
:
booleanShould the ViewRenderer render a view script?
Details_translateSpec(
array $vars
=
array
)
:
stringInflect 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
Detailsdirect(
string $action
=
null, string $name
=
null, boolean $noController
=
null
)
:
voidUse this helper as a method; proxies to setRender()
DetailsgetInflector(
)
:
Zend_Filter_InflectorGet inflector
DetailsgetModule(
)
:
stringGet current module name
DetailsgetModuleDirectory(
)
:
stringGet module directory
DetailsgetNeverController(
)
:
booleanRetrieve neverController flag value
DetailsgetNeverRender(
)
:
booleanRetrieve neverRender flag value
DetailsgetNoController(
)
:
booleanRetrieve noController flag value
DetailsgetNoRender(
)
:
booleanRetrieve noRender flag value
DetailsgetResponseSegment(
)
:
stringRetrieve named response segment name
DetailsgetScriptAction(
)
:
stringRetrieve view script name
DetailsgetViewBasePathSpec(
)
:
stringRetrieve the current view basePath specification string
DetailsgetViewScript(
string $action
=
null, array $vars
=
array
)
:
stringGet a view script based on an action and/or other variables
Uses values found in current request if no values passed in $vars.
If {@link $_noController} is set, uses {@link $_viewScriptPathNoControllerSpec}; otherwise, uses {@link $_viewScriptPathSpec}.
DetailsgetViewScriptPathNoControllerSpec(
)
:
stringRetrieve the current view script path specification string (no controller variant)
DetailsgetViewScriptPathSpec(
)
:
stringRetrieve the current view script path specification string
DetailsgetViewSuffix(
)
:
stringGet view script suffix
Detailsinit(
)
:
voidinit - initialize view
DetailsinitView(
string $path
=
null, string $prefix
=
null, array $options
=
array
)
:
voidInitialize 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
DetailspostDispatch(
)
:
voidpostDispatch - 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
Detailsrender(
string $action
=
null, string $name
=
null, boolean $noController
=
null
)
:
voidRender a view based on path specifications
Renders a view based on the view script path specifications.
DetailsrenderBySpec(
string $action
=
null, array $vars
=
array, string $name
=
null
)
:
voidRender 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.
DetailsrenderScript(
string $script, string $name
=
null
)
:
voidRender a view script (optionally to a named response segment)
Sets the noRender flag to true when called.
DetailssetInflector(
Zend_Filter_Inflector $inflector, boolean $reference
=
false
)
:
Zend_Controller_Action_Helper_ViewRendererSet inflector
DetailssetNeverController(
boolean $flag
=
true
)
:
Zend_Controller_Action_Helper_ViewRendererSet the neverController flag (i.e., whether or not to render into controller subdirectories)
DetailssetNeverRender(
boolean $flag
=
true
)
:
Zend_Controller_Action_Helper_ViewRendererSet the neverRender flag (i.e., globally dis/enable autorendering)
DetailssetNoController(
boolean $flag
=
true
)
:
Zend_Controller_Action_Helper_ViewRendererSet the noController flag (i.e., whether or not to render into controller subdirectories)
DetailssetNoRender(
boolean $flag
=
true
)
:
Zend_Controller_Action_Helper_ViewRendererSet the noRender flag (i.e., whether or not to autorender)
DetailssetRender(
string $action
=
null, string $name
=
null, boolean $noController
=
null
)
:
Zend_Controller_Action_Helper_ViewRendererSet options for rendering a view script
DetailssetResponseSegment(
string $name
)
:
Zend_Controller_Action_Helper_ViewRendererSet the response segment name
DetailssetScriptAction(
string $name
)
:
Zend_Controller_Action_Helper_ViewRendererSet the view script to use
DetailssetView(
Zend_View_Interface $view
)
:
Zend_Controller_Action_Helper_ViewRendererSet the view object
DetailssetViewBasePathSpec(
string $path
)
:
Zend_Controller_Action_Helper_ViewRendererSet 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
DetailssetViewScriptPathNoControllerSpec(
string $path
)
:
Zend_Controller_Action_Helper_ViewRendererSet 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.
DetailssetViewScriptPathSpec(
string $path
)
:
Zend_Controller_Action_Helper_ViewRendererSet 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
DetailssetViewSuffix(
string $suffix
)
:
Zend_Controller_Action_Helper_ViewRendererSet view script suffix
Details