Class ViewTask

Task class for creating and updating view files.

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

Properties summary

  • string
    Name of the controller being used
  • array

    An array of action names that don't require templates. These actions will not emit errors when doing bakeActions()

  • $path public
    array
    path to View directory
  • array
    Actions to use for scaffolding
  • $tasks public
    array
    Tasks to be loaded by this Task
  • $template public
    string
    The template file to use

Inherited Properties

Method Summary

  • _associations() protected
    Returns associations for controllers models.
  • _interactive() protected
    Handles interactive baking
  • _loadController() protected

    Loads Controller and sets variables for the template Available template variables 'modelClass', 'primaryKey', 'displayField', 'singularVar', 'pluralVar', 'singularHumanName', 'pluralHumanName', 'fields', 'foreignKeys', 'belongsTo', 'hasOne', 'hasMany', 'hasAndBelongsToMany'

  • _methodsToBake() protected
    Get a list of actions that can / should have views baked for them.
  • all() public
    Bake All views for All controllers.
  • bake() public
    Assembles and writes bakes the view file.
  • bakeActions() public
    Bake a view file for each of the supplied actions
  • handle creation of baking a custom action view file
  • execute() public
    Execution method always used for tasks
  • getContent() public
    Builds content from template and variables
  • Gets the option parser instance and configures it.
  • getTemplate() public
    Gets the template name based on the action name
  • initialize() public
    Override initialize

Method Detail

_associations()source protected

_associations( Model $model )

Returns associations for controllers models.

Parameters

Model $model
The Model instance.

Returns

array
associations

_interactive()source protected

_interactive( )

Handles interactive baking

_loadController()source protected

_loadController( )

Loads Controller and sets variables for the template Available template variables 'modelClass', 'primaryKey', 'displayField', 'singularVar', 'pluralVar', 'singularHumanName', 'pluralHumanName', 'fields', 'foreignKeys', 'belongsTo', 'hasOne', 'hasMany', 'hasAndBelongsToMany'

Returns

array
Returns a variables to be made available to a view template

_methodsToBake()source protected

_methodsToBake( )

Get a list of actions that can / should have views baked for them.

Returns

array
Array of action names that should be baked

all()source public

all( )

Bake All views for All controllers.

bake()source public

bake( string $action , string $content '' )

Assembles and writes bakes the view file.

Parameters

string $action
Action to bake
string $content optional ''
Content to write

Returns

boolean
Success

bakeActions()source public

bakeActions( array $actions , array $vars )

Bake a view file for each of the supplied actions

Parameters

array $actions
Array of actions to make files for.
array $vars
The template variables.

customAction()source public

customAction( )

handle creation of baking a custom action view file

execute()source public

execute( )

Execution method always used for tasks

Returns

mixed

Overrides

BakeTask::execute()

getContent()source public

getContent( string $action , array $vars null )

Builds content from template and variables

Parameters

string $action
name to generate content to
array $vars optional null
passed for use in templates

Returns

string
content from template

getOptionParser()source public

getOptionParser( )

Gets the option parser instance and configures it.

Returns

ConsoleOptionParser

getTemplate()source public

getTemplate( string $action )

Gets the template name based on the action name

Parameters

string $action
name

Returns

string
template name

initialize()source public

initialize( )

Override initialize

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

$controllerNamesource

public string

Name of the controller being used

null

$noTemplateActionssource

public array

An array of action names that don't require templates. These actions will not emit errors when doing bakeActions()

array('delete')

$pathsource

public array

path to View directory

null

$scaffoldActionssource

public array

Actions to use for scaffolding

array('index', 'view', 'add', 'edit')

$taskssource

public array

Tasks to be loaded by this Task

array('Project', 'Controller', 'DbConfig', 'Template')

$templatesource

public string

The template file to use

null

© 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-ViewTask.html