Class ControllerTask

Task class for creating and updating controller files.

AppShell
Extended by BakeTask
Extended by ControllerTask
Package: Cake\Console\Command\Task
Copyright: Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
License: MIT License
Location: Cake/Console/Command/Task/ControllerTask.php

Properties summary

  • $path public
    array
    path to Controller directory
  • $tasks public
    array
    Tasks to be loaded by this Task

Inherited Properties

Method Summary

  • _askAboutMethods() protected
    Interact with the user and ask about which methods (admin or regular they want to bake)
  • Common code for property choice handling.
  • _interactive() protected
    Interactive
  • all() public
    Bake All the controllers at once. Will only bake controllers for models that exist.
  • bake() public
    Assembles and writes a Controller file
  • bakeActions() public
    Bake scaffold actions
  • bakeTest() public
    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
  • doHelpers() public
    Interact with the user and get a list of additional helpers
  • execute() public
    Execution method always used for tasks
  • getName() public
    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.
  • initialize() public
    Override initialize
  • listAll() public
    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()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

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.

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

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

$pathsource

public array

path to Controller directory

null

$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