Class ControllerTask
Task class for creating and updating controller files.
- AppShell
- BakeTask
- ControllerTask
Properties summary
-
array
path to Controller directory -
array
Tasks to be loaded by this Task
Inherited Properties
Method Summary
- Interact with the user and ask about which methods (admin or regular they want to bake)
- Common code for property choice handling.
- Interactive
- Bake All the controllers at once. Will only bake controllers for models that exist.
- Assembles and writes a Controller file
- Bake scaffold actions
- Assembles and writes a unit test file
- Confirm a to be baked controller with the user
- Interact with the user and get a list of additional components
- Interact with the user and get a list of additional helpers
- Execution method always used for tasks
- Forces the user to specify the controller he wants to bake, and returns the selected controller name.
- Gets the option parser instance and configures it.
- Override initialize
- Outputs 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
array
Array 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
array
Array of values for property.
_interactive()source protected
_interactive( )
Interactive
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
string
Baked 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
string
Baked actions
bakeTest()source public
bakeTest( string $className )
Assembles and writes a unit test file
Parameters
- string
$className
- Controller class name
Returns
string
Baked 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
array
Components the user wants to use.
doHelpers()source public
doHelpers( )
Interact with the user and get a list of additional helpers
Returns
array
Helpers that the user wants to use.
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
string
Controller name
getOptionParser()source public
getOptionParser( )
Gets the option parser instance and configures it.
Returns
ConsoleOptionParser
initialize()source public
initialize( )
Override initialize
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
array
Set 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
string
Path 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
public array
path to Controller directory
public array
Tasks to be loaded by this Task
array('Model', 'Test', 'Template', 'DbConfig', 'Project')