Class Scaffold
Scaffolding is a set of automatic actions for starting web development work faster.
Scaffold inspects your database tables, and making educated guesses, sets up a number of pages for each of your Models. These pages have data forms that work, and afford the web developer an early look at the data, and the possibility to over-ride scaffolded actions with custom-made ones.
Deprecated: 3.0.0 Dynamic scaffolding will be removed and replaced in 3.0
Copyright: Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
License: MIT License
Location: Cake/Controller/Scaffold.php
Properties summary
-
$_passedVarsprotectedList of variables to collect from the associated controllerarray -
$_validSessionprotectedValid session.boolean - Controller object
$controllerpublic -
$layoutpublicName of layout to use with this View.string -
$modelpublicName of current model this view context is attached tostring -
$namepublicName of the controller to scaffoldstring - Request object
$requestpublic -
$scaffoldTitlepublicTitle HTML element for current scaffolded viewstring -
$viewPathpublicPath to View.string
Method Summary
- __construct() publicConstruct and set up given controller with given parameters.
- _associations() protectedReturns associations for controllers models.
- _scaffold() protected
When methods are now present in a controller scaffoldView is used to call default Scaffold methods if:
public $scaffold;is placed in the controller's class definition. - _scaffoldDelete() protectedPerforms a delete on given scaffolded Model.
- _scaffoldError() protectedShow a scaffold error
- _scaffoldForm() protectedRenders an add or edit action for scaffolded model.
- _scaffoldIndex() protectedRenders index action of scaffolded model.
- _scaffoldSave() protectedSaves or updates the scaffolded model.
- _scaffoldView() protectedRenders a view action of scaffolded model.
- _sendMessage() protected
Sends a message to the user. Either uses Sessions or flash messages depending on the availability of a session
Method Detail
__construct()source public
__construct( Controller $controller , CakeRequest $request )
Construct and set up given controller with given parameters.
Parameters
-
Controller$controller - Controller to scaffold
-
CakeRequest$request - Request parameters.
Throws
MissingModelException_associations()source protected
_associations( )
Returns associations for controllers models.
Returns
arrayAssociations for model
_scaffold()source protected
_scaffold( CakeRequest $request )
When methods are now present in a controller scaffoldView is used to call default Scaffold methods if: public $scaffold; is placed in the controller's class definition.
Parameters
-
CakeRequest$request - Request object for scaffolding
Throws
MissingActionExceptionWhen methods are not scaffolded.
MissingDatabaseExceptionWhen the database connection is undefined.
_scaffoldDelete()source protected
_scaffoldDelete( CakeRequest $request )
Performs a delete on given scaffolded Model.
Parameters
-
CakeRequest$request - Request for scaffolding
Returns
mixedSuccess on delete, error if delete fails
Throws
MethodNotAllowedExceptionWhen HTTP method is not a DELETE
NotFoundExceptionWhen id being deleted does not exist.
_scaffoldError()source protected
_scaffoldError( )
Show a scaffold error
Returns
mixedA rendered view showing the error
_scaffoldForm()source protected
_scaffoldForm( string $action 'edit' )
Renders an add or edit action for scaffolded model.
Parameters
- string
$actionoptional 'edit' - Action (add or edit)
_scaffoldIndex()source protected
_scaffoldIndex( array $params )
Renders index action of scaffolded model.
Parameters
- array
$params - Parameters for scaffolding
Returns
mixedA rendered view listing rows from Models database table
_scaffoldSave()source protected
_scaffoldSave( CakeRequest $request , string $action 'edit' )
Saves or updates the scaffolded model.
Parameters
-
CakeRequest$request - Request Object for scaffolding
- string
$actionoptional 'edit' - add or edit
Returns
mixedSuccess on save/update, add/edit form if data is empty or error if save or update fails
Throws
NotFoundException_scaffoldView()source protected
_scaffoldView( CakeRequest $request )
Renders a view action of scaffolded model.
Parameters
-
CakeRequest$request - Request Object for scaffolding
Returns
mixedA rendered view of a row from Models database table
Throws
NotFoundException_sendMessage()source protected
_sendMessage( string $message , string $element 'default' )
Sends a message to the user. Either uses Sessions or flash messages depending on the availability of a session
Parameters
- string
$message - Message to display
- string
$elementoptional 'default' - Flash template to use
Returns
CakeResponse|nullProperties detail
$_passedVarssource
protected array
List of variables to collect from the associated controller
array(
'layout', 'name', 'viewPath', 'request'
)
© 2005–2017 The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/2.10/class-Scaffold.html