Class ScaffoldView
ScaffoldView provides specific view file loading features for scaffolded views.
Copyright: Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
License: License (http://www.opensource.org/licenses/mit-license.php)
Location: Cake/View/ScaffoldView.php
Inherited Properties
Method Summary
-
_getViewFileName() protected
Override _getViewFileName Appends special scaffolding views in.
Method Detail
_getViewFileName() protected ¶
_getViewFileName( string $name = null )
Override _getViewFileName Appends special scaffolding views in.
Parameters
- string $name optional null
- name of the view file to get.
Returns
action
Throws
Overrides
Methods inherited from ThemeView
__construct() public ¶
__construct( Controller
$controller )
Constructor for ThemeView sets $this->theme.
Parameters
-
Controller
$controller - Controller object to be rendered.
Overrides
_paths() protected ¶
_paths( string $plugin = null , boolean $cached = true )
Return all possible paths to find view files in order
Parameters
- string $plugin optional null
- The name of the plugin views are being found for.
- boolean $cached optional true
- Set to true to force dir scan.
Returns
paths
Overrides
Methods inherited from View
__get() public ¶
__get( string $name )
Magic accessor for helpers. Provides access to attributes that were deprecated.
Parameters
- string $name
- Name of the attribute to get.
Returns
_getElementFileName() protected ¶
_getElementFileName( string $name , string $plugin = null )
Finds an element filename, returns false on failure.
Parameters
- string $name
- The name of the element to find.
- string $plugin optional null
- The plugin name the element is in.
Returns
Either a string to the element filename or false when one can't be found.
_getExtensions() protected ¶
_getExtensions( )
Get the extensions that view files can use.
Returns
Array of extensions view files use.
_getLayoutFileName() protected ¶
_getLayoutFileName( string $name = null )
Returns layout filename for this template as a string.
Parameters
- string $name optional null
- The name of the layout to find.
Returns
Filename for layout file (.ctp).
Throws
_render() protected ¶
_render( string $___viewFn , array $___dataForView = array() )
Renders and returns output for given view filename with its array of data.
Parameters
- string $___viewFn
- Filename of the view
- array $___dataForView optional array()
- Data to include in rendered view. If empty the current View::$viewVars will be used.
Returns
Rendered output
addScript() public ¶
addScript( string $name , string $content = null )
Adds a script block or other element to be inserted in $scripts_for_layout in
the <head />
of a document layout
Parameters
- string $name
Either the key name for the script, or the script content. Name can be used to update/replace a script element.
- string $content optional null
- The content of the script being added, optional.
element() public ¶
element( string $name , array $data = array() , array $options = array() )
Renders a piece of PHP with provided parameters and returns HTML, XML, or any other string.
This realizes the concept of Elements, (or "partial layouts") and the $params array is used to send
data to be used in the element. Elements can be cached improving performance by using the cache
option.
Parameters
- string $name
- Name of template file in the/app/View/Elements/ folder
- array $data optional array()
- Array of data to be made available to the rendered view (i.e. the Element)
- array $options optional array()
Array of options. Possible keys are: -
cache
- Can either betrue
, to enable caching using the config in View::$elementCache. Or an array If an array, the following keys can be used: -config
- Used to store the cached element in a custom cache configuration. -key
- Used to define the key used in the Cache::write(). It will be prefixed withelement_
-plugin
- Load an element from a specific plugin. -callbacks
- Set to true to fire beforeRender and afterRender helper callbacks for this element. Defaults to false.
Returns
Rendered Element
getVar() public ¶
getVar( string $var )
Returns the contents of the given View variable(s)
Parameters
- string $var
- The view var you want the contents of.
Returns
The content of the named var if its set, otherwise null.
getVars() public ¶
getVars( )
Returns a list of variables available in the current View context
Returns
Array of the set view variable names.
loadHelper() public ¶
loadHelper( string $helperName , array $settings = array() )
Loads a helper. Delegates to the HelperCollection::load()
to load the helper
Parameters
- string $helperName
- Name of the helper to load.
- array $settings optional array()
- Settings for the helper
Returns
See
render() public ¶
render( string $view = null , string $layout = null )
Renders view for given view file and layout.
Render triggers helper callbacks, which are fired before and after the view are rendered, as well as before and after the layout. The helper callbacks are called:
beforeRender
afterRender
beforeLayout
afterLayout
If View::$autoRender is false and no $layout
is provided, the view will be returned bare.
Parameters
- string $view optional null
- Name of view file to use
- string $layout optional null
- Layout to use.
Returns
Rendered Element
Throws
renderCache() public ¶
renderCache( string $filename , string $timeStart )
Render cached view. Works in concert with CacheHelper and Dispatcher to render cached view files.
Parameters
- string $filename
- the cache file to include
- string $timeStart
- the page render start time
Returns
Success of rendering the cached file.
renderLayout() public ¶
renderLayout( string $content_for_layout , string $layout = null )
Renders a layout. Returns output from _render(). Returns false on error. Several variables are created for use in layout.
title_for_layout
- A backwards compatible place holder, you should set this value if you want more control.content_for_layout
- contains rendered view filescripts_for_layout
- contains scripts added to header
Parameters
- string $content_for_layout
- Content to render in a view, wrapped by the surrounding layout.
- string $layout optional null
- Layout name
Returns
Rendered output, or false on error
Throws
set() public ¶
set( mixed $one , mixed $two = null )
Allows a template or element to set a variable that will be available in a layout or other element. Analogous to Controller::set().
Parameters
- mixed $one
- A string or an array of data.
- mixed $two optional null
Value in case $one is a string (which then works as the key). Unused if $one is an associative array, otherwise serves as the values to $one's keys.
Methods inherited from Object
_mergeVars() protected ¶
_mergeVars( array $properties , string $class , boolean $normalize = true )
Merges this objects $property with the property in $class' definition. This classes value for the property will be merged on top of $class'
This provides some of the DRY magic CakePHP provides. If you want to shut it off, redefine this method as an empty function.
Parameters
- array $properties
- The name of the properties to merge.
- string $class
- The class to merge the property with.
- boolean $normalize optional true
- Set to true to run the properties through Set::normalize() before merging.
_set() protected ¶
_set( array $properties = array() )
Allows setting of multiple properties of the object in a single line of code. Will only set properties that are part of a class declaration.
Parameters
- array $properties optional array()
- An associative array containing properties and corresponding values.
_stop() protected ¶
_stop( integer|string $status = 0 )
Stop execution of the current script. Wraps exit() making testing easier.
Parameters
- integer|string $status optional 0
- see http://php.net/exit for values
dispatchMethod() public ¶
dispatchMethod( string $method , array $params = array() )
Calls a method on this object with the given parameters. Provides an OO wrapper
for call_user_func_array
Parameters
- string $method
- Name of the method to call
- array $params optional array()
- Parameter list to use when calling $method
Returns
Returns the result of the method call
log() public ¶
log( string $msg , integer $type = LOG_ERROR )
Convenience method to write a message to CakeLog. See CakeLog::write() for more information on writing to logs.
Parameters
- string $msg
- Log message
- integer $type optional LOG_ERROR
- Error type constant. Defined in app/Config/core.php.
Returns
Success of log write
requestAction() public ¶
requestAction( mixed $url , array $extra = array() )
Calls a controller's method from any location. Can be used to connect controllers together or tie plugins into a main application. requestAction can be used to return rendered views or fetch the return value from controller actions.
Under the hood this method uses Router::reverse() to convert the $url parameter into a string URL. You should use URL formats that are compatible with Router::reverse()
Passing POST and GET data
POST and GET data can be simulated in requestAction. Use $extra['url']
for
GET data. The $extra['data']
parameter allows POST data simulation.
Parameters
- mixed $url
String or array-based url. Unlike other url arrays in CakePHP, this url will not automatically handle passed and named arguments in the $url parameter.
- array $extra optional array()
if array includes the key "return" it sets the AutoRender to true. Can also be used to submit GET/POST data, and named/passed arguments.
Returns
Boolean true or false on success/failure, or contents of rendered action if 'return' is set in $extra.
toString() public ¶
toString( )
Object-to-string conversion. Each class can override this method as necessary.
Returns
The name of this class