API Documentation

Controller/Action/Helper/ViewRenderer.php

Includes Classes 
category
Zend
copyright
Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
license
http://framework.zend.com/license/new-bsd New BSD License
package
Zend_Controller
subpackage
Zend_Controller_Action_Helper
version
$Id: ViewRenderer.php 20261 2010-01-13 18:55:25Z matthew $
Classes
Zend_Controller_Action_Helper_ViewRenderer

Description

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.

Zend_Controller_Action_Helper_ViewRenderer

Extends from
Zend_Controller_Action_Helper_Abstract
copyright
Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
license
http://framework.zend.com/license/new-bsd New BSD License
package
Zend_Controller
subpackage
Zend_Controller_Action_Helper
uses
Zend_Controller_Action_Helper_Abstract
Properties
$view
$_delimiters
$_inflector
$_inflectorTarget
$_moduleDir
$_neverController
$_neverRender
$_noController
$_noRender
$_pathDelimiters
$_responseSegment
$_scriptAction
$_viewBasePathSpec
$_viewScriptPathSpec
$_viewScriptPathNoControllerSpec
$_viewSuffix
Methods
__construct
__clone
setView
getModule
getModuleDirectory
getInflector
setInflector
_setInflectorTarget
_setModuleDir
_getModuleDir
_generateDefaultPrefix
_getBasePath
_setOptions
initView
init
setViewBasePathSpec
getViewBasePathSpec
setViewScriptPathSpec
getViewScriptPathSpec
setViewScriptPathNoControllerSpec
getViewScriptPathNoControllerSpec
getViewScript
setNeverRender
getNeverRender
setNoRender
getNoRender
setScriptAction
getScriptAction
setResponseSegment
getResponseSegment
setNoController
getNoController
setNeverController
getNeverController
setViewSuffix
getViewSuffix
setRender
_translateSpec
renderScript
render
renderBySpec
postDispatch
_shouldRender
direct

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: // 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');

Properties

$_delimiters

array $_delimiters = ''

Word delimiters

Details

$_delimiters
array
visibility
protected
default
final
false
static
false

$_inflector

Zend_Filter_Inflector $_inflector = ''

Details

$_inflector
Zend_Filter_Inflector
visibility
protected
default
final
false
static
false

$_inflectorTarget

string $_inflectorTarget = ''

Inflector target

Details

$_inflectorTarget
string
visibility
protected
default
final
false
static
false

$_moduleDir

string $_moduleDir = ''

Current module directory

Details

$_moduleDir
string
visibility
protected
default
final
false
static
false

$_neverController

boolean $_neverController = 'false'

Whether or not to autorender using controller name as subdirectory; global setting (not reset at next invocation)

Details

$_neverController
boolean
visibility
protected
default
false
final
false
static
false

$_neverRender

boolean $_neverRender = 'false'

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

Details

$_neverRender
boolean
visibility
protected
default
false
final
false
static
false

$_noController

boolean $_noController = 'false'

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

Details

$_noController
boolean
visibility
protected
default
false
final
false
static
false

$_noRender

boolean $_noRender = 'false'

Whether or not to autorender postDispatch; per controller/action setting (reset at next invocation)

Details

$_noRender
boolean
visibility
protected
default
false
final
false
static
false

$_pathDelimiters

string|array $_pathDelimiters = ''

Characters representing path delimiters in the controller

Details

$_pathDelimiters
string|array
visibility
protected
default
final
false
static
false

$_responseSegment

string $_responseSegment = 'null'

Which named segment of the response to utilize

Details

$_responseSegment
string
visibility
protected
default
null
final
false
static
false

$_scriptAction

string $_scriptAction = 'null'

Which action view script to render

Details

$_scriptAction
string
visibility
protected
default
null
final
false
static
false

$_viewBasePathSpec

string $_viewBasePathSpec = ':moduleDir/views'

View object basePath

Details

$_viewBasePathSpec
string
visibility
protected
default
:moduleDir/views
final
false
static
false

$_viewScriptPathNoControllerSpec

string $_viewScriptPathNoControllerSpec = ':action.:suffix'

View script path specification string, minus controller segment

Details

$_viewScriptPathNoControllerSpec
string
visibility
protected
default
:action.:suffix
final
false
static
false

$_viewScriptPathSpec

string $_viewScriptPathSpec = ':controller/:action.:suffix'

View script path specification string

Details

$_viewScriptPathSpec
string
visibility
protected
default
:controller/:action.:suffix
final
false
static
false

$_viewSuffix

string $_viewSuffix = 'phtml'

View script suffix

Details

$_viewSuffix
string
visibility
protected
default
phtml
final
false
static
false

$view

Zend_View_Interface $view = ''

Details

$view
Zend_View_Interface
visibility
public
default
final
false
static
false

Methods

__clone

__clone( ) : void

Clone - also make sure the view is cloned.

Details
visibility
public
final
false
static
false

__construct

__construct( Zend_View_Interface $view = null, array $options = array ) : void

Constructor

Optionally set view object and options.

Arguments
$view
Zend_View_Interface
$options
array
Details
visibility
public
final
false
static
false

_generateDefaultPrefix

_generateDefaultPrefix( ) : string

Generate a class prefix for helper and filter classes

Output
string
Details
visibility
protected
final
false
static
false

_getBasePath

_getBasePath( ) : string

Retrieve base path based on location of current action controller

Output
string
Details
visibility
protected
final
false
static
false

_getModuleDir

_getModuleDir( ) : string

Get internal module directory representation

Output
string
Details
visibility
protected
final
false
static
false

_setInflectorTarget

_setInflectorTarget( string $target ) : void

Set inflector target

Arguments
$target
string
Details
visibility
protected
final
false
static
false

_setModuleDir

_setModuleDir( string $dir ) : void

Set internal module directory representation

Arguments
$dir
string
Details
visibility
protected
final
false
static
false

_setOptions

_setOptions( array $options ) : Zend_Controller_Action_Helper_ViewRenderer

Set options

Arguments
$options
array
Output
Zend_Controller_Action_Helper_ViewRenderer
Provides a fluent interface
Details
visibility
protected
final
false
static
false

_shouldRender

_shouldRender( ) : boolean

Should the ViewRenderer render a view script?

Output
boolean
Details
visibility
protected
final
false
static
false

_translateSpec

_translateSpec( array $vars = array ) : string

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

Arguments
$vars
array
Output
string
Details
visibility
protected
final
false
static
false

direct

direct( string $action = null, string $name = null, boolean $noController = null ) : void

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

Arguments
$action
string
$name
string
$noController
boolean
Details
visibility
public
final
false
static
false

getInflector

getInflector( ) : Zend_Filter_Inflector

Get inflector

Details
visibility
public
final
false
static
false

getModule

getModule( ) : string

Get current module name

Output
string
Details
visibility
public
final
false
static
false

getModuleDirectory

getModuleDirectory( ) : string

Get module directory

Output
string
Details
visibility
public
final
false
static
false
throws

getNeverController

getNeverController( ) : boolean

Retrieve neverController flag value

Output
boolean
Details
visibility
public
final
false
static
false

getNeverRender

getNeverRender( ) : boolean

Retrieve neverRender flag value

Output
boolean
Details
visibility
public
final
false
static
false

getNoController

getNoController( ) : boolean

Retrieve noController flag value

Output
boolean
Details
visibility
public
final
false
static
false

getNoRender

getNoRender( ) : boolean

Retrieve noRender flag value

Output
boolean
Details
visibility
public
final
false
static
false

getResponseSegment

getResponseSegment( ) : string

Retrieve named response segment name

Output
string
Details
visibility
public
final
false
static
false

getScriptAction

getScriptAction( ) : string

Retrieve view script name

Output
string
Details
visibility
public
final
false
static
false

getViewBasePathSpec

getViewBasePathSpec( ) : string

Retrieve the current view basePath specification string

Output
string
Details
visibility
public
final
false
static
false

getViewScript

getViewScript( string $action = null, array $vars = array ) : string

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 {@link $_noController} is set, uses {@link $_viewScriptPathNoControllerSpec}; otherwise, uses {@link $_viewScriptPathSpec}.

Arguments
$action
string
$vars
array
Output
string
Details
visibility
public
final
false
static
false

getViewScriptPathNoControllerSpec

getViewScriptPathNoControllerSpec( ) : string

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

Output
string
Details
visibility
public
final
false
static
false

getViewScriptPathSpec

getViewScriptPathSpec( ) : string

Retrieve the current view script path specification string

Output
string
Details
visibility
public
final
false
static
false

getViewSuffix

getViewSuffix( ) : string

Get view script suffix

Output
string
Details
visibility
public
final
false
static
false

init

init( ) : void

init - initialize view

Details
visibility
public
final
false
static
false

initView

initView( string $path = null, string $prefix = null, array $options = array ) : void

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

Arguments
$path
string
$prefix
string
$options
array
Details
visibility
public
final
false
static
false
throws

postDispatch

postDispatch( ) : void

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

Details
visibility
public
final
false
static
false

render

render( string $action = null, string $name = null, boolean $noController = null ) : void

Render a view based on path specifications

Renders a view based on the view script path specifications.

Arguments
$action
string
$name
string
$noController
boolean
Details
visibility
public
final
false
static
false

renderBySpec

renderBySpec( string $action = null, array $vars = array, string $name = null ) : void

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.

Arguments
$action
string
$vars
array
$name
string
Details
visibility
public
final
false
static
false

renderScript

renderScript( string $script, string $name = null ) : void

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

Sets the noRender flag to true when called.

Arguments
$script
string
$name
string
Details
visibility
public
final
false
static
false

setInflector

setInflector( Zend_Filter_Inflector $inflector, boolean $reference = false ) : Zend_Controller_Action_Helper_ViewRenderer

Set inflector

Arguments
$inflector
Zend_Filter_Inflector
$reference
boolean
Whether the moduleDir, target, and suffix should be set as references to ViewRenderer properties
Output
Zend_Controller_Action_Helper_ViewRenderer
Provides a fluent interface
Details
visibility
public
final
false
static
false

setNeverController

setNeverController( boolean $flag = true ) : Zend_Controller_Action_Helper_ViewRenderer

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

Arguments
$flag
boolean
Output
Zend_Controller_Action_Helper_ViewRenderer
Provides a fluent interface
Details
visibility
public
final
false
static
false

setNeverRender

setNeverRender( boolean $flag = true ) : Zend_Controller_Action_Helper_ViewRenderer

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

Arguments
$flag
boolean
Output
Zend_Controller_Action_Helper_ViewRenderer
Provides a fluent interface
Details
visibility
public
final
false
static
false

setNoController

setNoController( boolean $flag = true ) : Zend_Controller_Action_Helper_ViewRenderer

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

Arguments
$flag
boolean
Output
Zend_Controller_Action_Helper_ViewRenderer
Provides a fluent interface
Details
visibility
public
final
false
static
false

setNoRender

setNoRender( boolean $flag = true ) : Zend_Controller_Action_Helper_ViewRenderer

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

Arguments
$flag
boolean
Output
Zend_Controller_Action_Helper_ViewRenderer
Provides a fluent interface
Details
visibility
public
final
false
static
false

setRender

setRender( string $action = null, string $name = null, boolean $noController = null ) : Zend_Controller_Action_Helper_ViewRenderer

Set options for rendering a view script

Arguments
$action
string
View script to render
$name
string
Response named segment to render to
$noController
boolean
Whether or not to render within a subdirectory named after the controller
Output
Zend_Controller_Action_Helper_ViewRenderer
Provides a fluent interface
Details
visibility
public
final
false
static
false

setResponseSegment

setResponseSegment( string $name ) : Zend_Controller_Action_Helper_ViewRenderer

Set the response segment name

Arguments
$name
string
Output
Zend_Controller_Action_Helper_ViewRenderer
Provides a fluent interface
Details
visibility
public
final
false
static
false

setScriptAction

setScriptAction( string $name ) : Zend_Controller_Action_Helper_ViewRenderer

Set the view script to use

Arguments
$name
string
Output
Zend_Controller_Action_Helper_ViewRenderer
Provides a fluent interface
Details
visibility
public
final
false
static
false

setView

setView( Zend_View_Interface $view ) : Zend_Controller_Action_Helper_ViewRenderer

Set the view object

Arguments
$view
Zend_View_Interface
Output
Zend_Controller_Action_Helper_ViewRenderer
Provides a fluent interface
Details
visibility
public
final
false
static
false

setViewBasePathSpec

setViewBasePathSpec( string $path ) : Zend_Controller_Action_Helper_ViewRenderer

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

Arguments
$path
string
Output
Zend_Controller_Action_Helper_ViewRenderer
Provides a fluent interface
Details
visibility
public
final
false
static
false

setViewScriptPathNoControllerSpec

setViewScriptPathNoControllerSpec( string $path ) : Zend_Controller_Action_Helper_ViewRenderer

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.

Arguments
$path
string
Output
Zend_Controller_Action_Helper_ViewRenderer
Provides a fluent interface
Details
visibility
public
final
false
static
false

setViewScriptPathSpec

setViewScriptPathSpec( string $path ) : Zend_Controller_Action_Helper_ViewRenderer

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

Arguments
$path
string
Output
Zend_Controller_Action_Helper_ViewRenderer
Provides a fluent interface
Details
visibility
public
final
false
static
false

setViewSuffix

setViewSuffix( string $suffix ) : Zend_Controller_Action_Helper_ViewRenderer

Set view script suffix

Arguments
$suffix
string
Output
Zend_Controller_Action_Helper_ViewRenderer
Provides a fluent interface
Details
visibility
public
final
false
static
false
Documentation was generated by DocBlox.