Class TemplateTask
Template Task can generate templated output Used in other Tasks. Acts like a simplified View class.
- AppShell
- TemplateTask
Copyright: Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
License: MIT License
Location: Cake/Console/Command/Task/TemplateTask.php
Properties summary
-
$templatePaths
publicarray
Paths to look for templates on. Contains a list of $theme => $path
-
$templateVars
publicarray
variables to add to template scope
Method Summary
-
_findTemplate() protected
Find a template inside a directory inside a path. Will scan all other theme dirs if the template is not found in the first directory.
-
_findThemes() protected
Find the paths to all the installed shell themes in the app. -
generate() public
Runs the template -
getThemePath() public
Find the theme name for the current operation. If there is only one theme in $templatePaths it will be used. If there is a -theme param in the cli args, it will be used. If there is more than one installed theme user interaction will happen
-
initialize() public
Initialize callback. Setup paths for the template task. -
set() public
Set variable values to the template scope
Method Detail
_findTemplate() protected ¶
_findTemplate( string $path , string $directory , string $filename )
Find a template inside a directory inside a path. Will scan all other theme dirs if the template is not found in the first directory.
Parameters
- string $path
- The initial path to look for the file on. If it is not found fallbacks will be used.
- string $directory
- Subdirectory to look for ie. 'views', 'objects'
- string $filename
- lower_case_underscored filename you want.
Returns
filename will exit program if template is not found.
_findThemes() protected ¶
_findThemes( )
Find the paths to all the installed shell themes in the app.
Bake themes are directories not named skel
inside a Console/Templates
path.
They are listed in this order: app -> plugin -> default
Returns
Array of bake themes that are installed.
generate() public ¶
generate( string $directory , string $filename , array $vars = null )
Runs the template
Parameters
- string $directory
- directory / type of thing you want
- string $filename
- template name
- array $vars optional null
- Additional vars to set to template scope.
Returns
contents of generated code template
getThemePath() public ¶
getThemePath( )
Find the theme name for the current operation. If there is only one theme in $templatePaths it will be used. If there is a -theme param in the cli args, it will be used. If there is more than one installed theme user interaction will happen
Returns
returns the path to the selected theme.
set() public ¶
set( string|array $one , string|array $two = null )
Set variable values to the template scope
Parameters
- string|array $one
- A string or an array of data.
- string|array $two optional null
Value in case $one is a string (which then works as the key). Unused if $one is an associative array, otherwise serves as the values to $one's keys.
Properties detail
$templatePaths ¶
Paths to look for templates on. Contains a list of $theme => $path
array()