CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Reporting Security Issues
    • Privacy Policy
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Get Involved
    • Issues (GitHub)
    • Bakery
    • Featured Resources
    • Training
    • Meetups
    • My CakePHP
    • CakeFest
    • Newsletter
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • Help & Support
    • Forum
    • Stack Overflow
    • Slack
    • Paid Support
CakePHP

C CakePHP 2.4 API

  • Overview
  • Tree
  • Deprecated
  • Version:
    • 2.4
      • 4.2
      • 4.1
      • 4.0
      • 3.9
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Packages

  • Cake
    • Cache
      • Engine
    • Configure
    • Console
      • Command
        • Task
    • Controller
      • Component
        • Acl
        • Auth
    • Core
    • Error
    • Event
    • I18n
    • Log
      • Engine
    • Model
      • Behavior
      • Datasource
        • Database
        • Session
      • Validator
    • Network
      • Email
      • Http
    • Routing
      • Filter
      • Route
    • TestSuite
      • Coverage
      • Fixture
      • Reporter
    • Utility
    • View
      • Helper

Classes

  • BakeTask
  • ControllerTask
  • DbConfigTask
  • ExtractTask
  • FixtureTask
  • ModelTask
  • PluginTask
  • ProjectTask
  • TemplateTask
  • TestTask
  • ViewTask

Class TemplateTask

Template Task can generate templated output Used in other Tasks. Acts like a simplified View class.

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

Properties summary

  • $templatePaths public
    array

    Paths to look for templates on. Contains a list of $theme => $path

  • $templateVars public
    array
    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
string
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
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
string
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
string
returns the path to the selected theme.

initialize() public ¶

initialize( )

Initialize callback. Setup paths for the template task.

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 ¶

public array

Paths to look for templates on. Contains a list of $theme => $path

array()

$templateVars ¶

public array

variables to add to template scope

array()
OpenHub
Rackspace
Rackspace
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Reporting Security Issues
  • Privacy Policy
  • Logos & Trademarks
  • Community
  • Get Involved
  • Issues (GitHub)
  • Bakery
  • Featured Resources
  • Training
  • Meetups
  • My CakePHP
  • CakeFest
  • Newsletter
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • Help & Support
  • Forum
  • Stack Overflow
  • Slack
  • Paid Support

Generated using CakePHP API Docs