On this page
Class ControllerTask
Task class for creating and updating controller files.
- AppShell
BakeTask
ControllerTask
Copyright: Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
License: MIT License
Location: Cake/Console/Command/Task/ControllerTask.php
Properties summary
Inherited Properties
Method Summary
-
_askAboutMethods() protectedInteract with the user and ask about which methods (admin or regular they want to bake)
-
_doPropertyChoices() protectedCommon code for property choice handling.
-
_interactive() protectedInteractive
-
all() publicBake All the controllers at once. Will only bake controllers for models that exist.
-
bake() publicAssembles and writes a Controller file
-
bakeActions() publicBake scaffold actions
-
bakeTest() publicAssembles and writes a unit test file
-
confirmController() publicConfirm a to be baked controller with the user
-
doComponents() publicInteract with the user and get a list of additional components
-
doHelpers() publicInteract with the user and get a list of additional helpers
-
execute() publicExecution method always used for tasks
-
getName() publicForces the user to specify the controller he wants to bake, and returns the selected controller name.
-
getOptionParser() publicGets the option parser instance and configures it.
-
initialize() publicOverride initialize
-
listAll() publicOutputs and gets the list of possible controllers from database
Method Detail
_askAboutMethods()source protected
_askAboutMethods( )
Interact with the user and ask about which methods (admin or regular they want to bake)
Returns
arrayArray containing (bakeRegular, bakeAdmin) answers
_doPropertyChoices()source protected
_doPropertyChoices( string $prompt , string $example )
Common code for property choice handling.
Parameters
-
string
$prompt
- A yes/no question to precede the list
-
string
$example
- A question for a comma separated list, with examples.
Returns
arrayArray of values for property.
all()source public
all( )
Bake All the controllers at once. Will only bake controllers for models that exist.
bake()source public
bake( string $controllerName , string $actions '' , array $helpers null , array $components null )
Assembles and writes a Controller file
Parameters
-
string
$controllerName
- Controller name already pluralized and correctly cased.
-
string
$actions
optional '' - Actions to add, or set the whole controller to use $scaffold (set $actions to 'scaffold')
-
array
$helpers
optional null - Helpers to use in controller
-
array
$components
optional null - Components to use in controller
Returns
stringBaked controller
bakeActions()source public
bakeActions( string $controllerName , string $admin null , boolean $wannaUseSession true )
Bake scaffold actions
Parameters
-
string
$controllerName
- Controller name
-
string
$admin
optional null - Admin route to use
-
boolean
$wannaUseSession
optional true - Set to true to use sessions, false otherwise
Returns
stringBaked actions
bakeTest()source public
bakeTest( string $className )
Assembles and writes a unit test file
Parameters
-
string
$className
- Controller class name
Returns
stringBaked test
confirmController()source public
confirmController( string $controllerName , string $useDynamicScaffold , array $helpers , array $components )
Confirm a to be baked controller with the user
Parameters
-
string
$controllerName
- The name of the controller.
-
string
$useDynamicScaffold
- Whether or not to use dynamic scaffolds.
-
array
$helpers
- The list of helpers to include.
-
array
$components
- The list of components to include.
doComponents()source public
doComponents( )
Interact with the user and get a list of additional components
Returns
arrayComponents the user wants to use.
doHelpers()source public
doHelpers( )
Interact with the user and get a list of additional helpers
Returns
arrayHelpers that the user wants to use.
execute()source public
execute( )
Execution method always used for tasks
Overrides
BakeTask::execute()
getName()source public
getName( string $useDbConfig null )
Forces the user to specify the controller he wants to bake, and returns the selected controller name.
Parameters
-
string
$useDbConfig
optional null - Connection name to get a controller name for.
Returns
stringController name
getOptionParser()source public
getOptionParser( )
Gets the option parser instance and configures it.
Returns
ConsoleOptionParser
listAll()source public
listAll( string $useDbConfig null )
Outputs and gets the list of possible controllers from database
Parameters
-
string
$useDbConfig
optional null - Database configuration name
Returns
arraySet of controllers
Methods inherited from BakeTask
getPath()source public
getPath( )
Gets the path for output. Checks the plugin property and returns the correct path.
Returns
stringPath to output.
startup()source public
startup( )
Disable caching and enable debug for baking. This forces the most current database schema to be used.
Properties detail
$taskssource
public array
Tasks to be loaded by this Task
array('Model', 'Test', 'Template', 'DbConfig', 'Project')
© 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-ControllerTask.html