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. (https://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
publicvariables to add to template scopearray
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() protectedFind the paths to all the installed shell themes in the app.
- generate() publicRuns 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() publicInitialize callback. Setup paths for the template task.
- set() publicSet variable values to the template scope
Method Detail
_findTemplate()source 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
stringfilename will exit program if template is not found.
_findThemes()source 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
arrayArray of bake themes that are installed.
generate()source 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
stringcontents of generated code template
getThemePath()source 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
stringreturns the path to the selected theme.
set()source 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
$templatePathssource
public array
Paths to look for templates on. Contains a list of $theme => $path
array()
© 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-TemplateTask.html