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.

Package: Cake\Controller
Deprecated: 3.0.0 Dynamic scaffolding will be removed and replaced in 3.0
Copyright: Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
License: MIT License
Located at Cake/Controller/Scaffold.php

Method Detail

__constructsource 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
MissingModelException

_associationssource protected

_associations( )

Returns associations for controllers models.

Returns

array
Associations for model

_scaffoldsource 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

MissingActionException
When methods are not scaffolded.
MissingDatabaseException
When the database connection is undefined.

_scaffoldDeletesource protected

_scaffoldDelete( CakeRequest $request )

Performs a delete on given scaffolded Model.

Parameters

CakeRequest $request
Request for scaffolding

Returns

mixed
Success on delete, error if delete fails

Throws

MethodNotAllowedException
When HTTP method is not a DELETE
NotFoundException
When id being deleted does not exist.

_scaffoldErrorsource protected

_scaffoldError( )

Show a scaffold error

Returns

mixed
A rendered view showing the error

_scaffoldFormsource protected

_scaffoldForm( string $action 'edit' )

Renders an add or edit action for scaffolded model.

Parameters

string $action optional 'edit'
Action (add or edit)

_scaffoldIndexsource protected

_scaffoldIndex( array $params )

Renders index action of scaffolded model.

Parameters

array $params
Parameters for scaffolding

Returns

mixed
A rendered view listing rows from Models database table

_scaffoldSavesource protected

_scaffoldSave( CakeRequest $request , string $action 'edit' )

Saves or updates the scaffolded model.

Parameters

CakeRequest $request
Request Object for scaffolding
string $action optional 'edit'
add or edit

Returns

mixed
Success on save/update, add/edit form if data is empty or error if save or update fails

Throws

NotFoundException
NotFoundException

_scaffoldViewsource protected

_scaffoldView( CakeRequest $request )

Renders a view action of scaffolded model.

Parameters

CakeRequest $request
Request Object for scaffolding

Returns

mixed
A rendered view of a row from Models database table

Throws

NotFoundException
NotFoundException

_sendMessagesource 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 $element optional 'default'
Flash template to use

Properties summary

$_passedVarssource

protected array

List of variables to collect from the associated controller

array(
    'layout', 'name', 'viewPath', 'request'
)

$_validSessionsource

protected boolean

Valid session.

null

$controllersource

public Controller

Controller object

null

$layoutsource

public string

Name of layout to use with this View.

'default'

$modelsource

public string

Name of current model this view context is attached to

null

$namesource

public string

Name of the controller to scaffold

null

$requestsource

public CakeRequest

Request object

$scaffoldTitlesource

public string

Title HTML element for current scaffolded view

null

$viewPathsource

public string

Path to View.

© 2005–2016 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.
http://api.cakephp.org/2.7/class-Scaffold.html