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 1.2 API

  • Overview
  • Tree
  • Deprecated
  • Version:
    • 1.2
      • 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

Classes

  • AclBase
  • AclBehavior
  • AclComponent
  • AclNode
  • AclShell
  • Aco
  • AcoAction
  • AjaxHelper
  • ApcEngine
  • ApiShell
  • App
  • AppController
  • AppHelper
  • AppModel
  • Aro
  • AuthComponent
  • BakeShell
  • BehaviorCollection
  • Cache
  • CacheEngine
  • CacheHelper
  • CakeErrorController
  • CakeLog
  • CakeSchema
  • CakeSession
  • CakeSocket
  • ClassRegistry
  • Component
  • Configure
  • ConnectionManager
  • ConsoleShell
  • ContainableBehavior
  • Controller
  • ControllerTask
  • CookieComponent
  • DataSource
  • DbAcl
  • DbAclSchema
  • DbConfigTask
  • DboAdodb
  • DboDb2
  • DboFirebird
  • DboMssql
  • DboMysql
  • DboMysqlBase
  • DboMysqli
  • DboOdbc
  • DboOracle
  • DboPostgres
  • DboSource
  • DboSqlite
  • DboSybase
  • Debugger
  • EmailComponent
  • ErrorHandler
  • ExtractTask
  • File
  • FileEngine
  • Flay
  • Folder
  • FormHelper
  • Helper
  • HtmlHelper
  • HttpSocket
  • I18n
  • I18nModel
  • i18nSchema
  • I18nShell
  • Inflector
  • IniAcl
  • JavascriptHelper
  • JsHelper
  • JsHelperObject
  • L10n
  • MagicDb
  • MagicFileResource
  • MediaView
  • MemcacheEngine
  • Model
  • ModelBehavior
  • ModelTask
  • Multibyte
  • NumberHelper
  • Object
  • Overloadable
  • Overloadable2
  • PagesController
  • PaginatorHelper
  • Permission
  • PluginTask
  • ProjectTask
  • RequestHandlerComponent
  • Router
  • RssHelper
  • Sanitize
  • Scaffold
  • ScaffoldView
  • SchemaShell
  • Security
  • SecurityComponent
  • SessionComponent
  • SessionHelper
  • SessionsSchema
  • Set
  • Shell
  • String
  • TestSuiteShell
  • TestTask
  • TextHelper
  • ThemeView
  • TimeHelper
  • TranslateBehavior
  • TreeBehavior
  • Validation
  • View
  • ViewTask
  • XcacheEngine
  • Xml
  • XmlElement
  • XmlHelper
  • XmlManager
  • XmlNode
  • XmlTextNode

Functions

  • __enclose
  • make_clean_css
  • mb_encode_mimeheader
  • mb_stripos
  • mb_stristr
  • mb_strlen
  • mb_strpos
  • mb_strrchr
  • mb_strrichr
  • mb_strripos
  • mb_strrpos
  • mb_strstr
  • mb_strtolower
  • mb_strtoupper
  • mb_substr
  • mb_substr_count
  • write_css_cache
  1: <?php
  2: /* SVN FILE: $Id$ */
  3: /**
  4:  * The Plugin Task handles creating an empty plugin, ready to be used
  5:  *
  6:  * Long description for file
  7:  *
  8:  * PHP versions 4 and 5
  9:  *
 10:  * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
 11:  * Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
 12:  *
 13:  * Licensed under The MIT License
 14:  * Redistributions of files must retain the above copyright notice.
 15:  *
 16:  * @copyright     Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
 17:  * @link          http://cakephp.org CakePHP(tm) Project
 18:  * @package       cake
 19:  * @subpackage    cake.cake.console.libs.tasks
 20:  * @since         CakePHP(tm) v 1.2
 21:  * @version       $Revision$
 22:  * @modifiedby    $LastChangedBy$
 23:  * @lastmodified  $Date$
 24:  * @license       http://www.opensource.org/licenses/mit-license.php The MIT License
 25:  */
 26: if (!class_exists('File')) {
 27:     uses('file');
 28: }
 29: /**
 30:  * Task class for creating a plugin
 31:  *
 32:  * @package       cake
 33:  * @subpackage    cake.cake.console.libs.tasks
 34:  */
 35: class PluginTask extends Shell {
 36: /**
 37:  * Tasks
 38:  *
 39:  */
 40:     var $tasks = array('Model', 'Controller', 'View');
 41: /**
 42:  * path to CONTROLLERS directory
 43:  *
 44:  * @var array
 45:  * @access public
 46:  */
 47:     var $path = null;
 48: /**
 49:  * initialize
 50:  *
 51:  * @return void
 52:  */
 53:     function initialize() {
 54:         $this->path = APP . 'plugins' . DS;
 55:     }
 56: /**
 57:  * Execution method always used for tasks
 58:  *
 59:  * @return void
 60:  */
 61:     function execute() {
 62:         if (empty($this->params['skel'])) {
 63:             $this->params['skel'] = '';
 64:             if (is_dir(CAKE_CORE_INCLUDE_PATH.DS.'cake'.DS.'console'.DS.'libs'.DS.'templates'.DS.'skel') === true) {
 65:                 $this->params['skel'] = CAKE_CORE_INCLUDE_PATH.DS.'cake'.DS.'console'.DS.'libs'.DS.'templates'.DS.'skel';
 66:             }
 67:         }
 68: 
 69:         $plugin = null;
 70: 
 71:         if (isset($this->args[0])) {
 72:             $plugin = Inflector::camelize($this->args[0]);
 73:             $pluginPath = Inflector::underscore($plugin) . DS;
 74:             $this->Dispatch->shiftArgs();
 75:             if (is_dir($this->path . $pluginPath)) {
 76:                 $this->out(sprintf('Plugin: %s', $plugin));
 77:                 $this->out(sprintf('Path: %s', $this->path . $pluginPath));
 78:                 $this->hr();
 79:             } elseif (isset($this->args[0])) {
 80:                 $this->err(sprintf('%s in path %s not found.', $plugin, $this->path . $pluginPath));
 81:                 $this->_stop();
 82:             } else {
 83:                 $this->__interactive($plugin);
 84:             }
 85:         }
 86: 
 87:         if (isset($this->args[0])) {
 88:             $task = Inflector::classify($this->args[0]);
 89:             $this->Dispatch->shiftArgs();
 90:             if (in_array($task, $this->tasks)) {
 91:                 $this->{$task}->plugin = $plugin;
 92:                 $this->{$task}->path = $this->path . $pluginPath . Inflector::underscore(Inflector::pluralize($task)) . DS;
 93: 
 94:                 if (!is_dir($this->{$task}->path)) {
 95:                     $this->err(sprintf(__("%s directory could not be found.\nBe sure you have created %s", true), $task, $this->{$task}->path));
 96:                 }
 97:                 $this->{$task}->loadTasks();
 98:                 $this->{$task}->execute();
 99:             }
100:         }
101:     }
102: 
103: /**
104:  * Interactive interface
105:  *
106:  * @access private
107:  * @return void
108:  */
109:     function __interactive($plugin = null) {
110:         while ($plugin === null) {
111:             $plugin = $this->in(__('Enter the name of the plugin in CamelCase format', true));
112:         }
113: 
114:         if (!$this->bake($plugin)) {
115:             $this->err(sprintf(__("An error occured trying to bake: %s in %s", true), $plugin, $this->path . $pluginPath));
116:         }
117:     }
118: 
119: /**
120:  * Bake the plugin, create directories and files
121:  *
122:  * @params $plugin name of the plugin in CamelCased format
123:  * @access public
124:  * @return bool
125:  */
126:     function bake($plugin) {
127: 
128:         $pluginPath = Inflector::underscore($plugin);
129: 
130:         $this->hr();
131:         $this->out("Plugin Name: $plugin");
132:         $this->out("Plugin Directory: {$this->path}{$pluginPath}");
133:         $this->hr();
134: 
135: 
136:         $looksGood = $this->in('Look okay?', array('y', 'n', 'q'), 'y');
137: 
138:         if (strtolower($looksGood) == 'y' || strtolower($looksGood) == 'yes') {
139:             $verbose = $this->in(__('Do you want verbose output?', true), array('y', 'n'), 'n');
140: 
141:             $Folder = new Folder($this->path . $pluginPath);
142:             $directories = array('models' . DS . 'behaviors', 'controllers' . DS . 'components', 'views' . DS . 'helpers');
143: 
144:             foreach ($directories as $directory) {
145:                 $Folder->create($this->path . $pluginPath . DS . $directory);
146:             }
147: 
148:             if (strtolower($verbose) == 'y' || strtolower($verbose) == 'yes') {
149:                 foreach ($Folder->messages() as $message) {
150:                     $this->out($message);
151:                 }
152:             }
153: 
154:             $errors = $Folder->errors();
155:             if (!empty($errors)) {
156:                 return false;
157:             }
158: 
159:             $controllerFileName = $pluginPath . '_app_controller.php';
160: 
161:             $out = "<?php\n\n";
162:             $out .= "class {$plugin}AppController extends AppController {\n\n";
163:             $out .= "}\n\n";
164:             $out .= "?>";
165:             $this->createFile($this->path . $pluginPath. DS . $controllerFileName, $out);
166: 
167:             $modelFileName = $pluginPath . '_app_model.php';
168: 
169:             $out = "<?php\n\n";
170:             $out .= "class {$plugin}AppModel extends AppModel {\n\n";
171:             $out .= "}\n\n";
172:             $out .= "?>";
173:             $this->createFile($this->path . $pluginPath . DS . $modelFileName, $out);
174: 
175:             $this->hr();
176:             $this->out(sprintf(__("Created: %s in %s", true), $plugin, $this->path . $pluginPath));
177:             $this->hr();
178:         }
179: 
180:         return true;
181:     }
182: /**
183:  * Help
184:  *
185:  * @return void
186:  * @access public
187:  */
188:     function help() {
189:         $this->hr();
190:         $this->out("Usage: cake bake plugin <arg1> <arg2>...");
191:         $this->hr();
192:         $this->out('Commands:');
193:         $this->out("\n\tplugin <name>\n\t\tbakes plugin directory structure");
194:         $this->out("\n\tplugin <name> model\n\t\tbakes model. Run 'cake bake model help' for more info.");
195:         $this->out("\n\tplugin <name> controller\n\t\tbakes controller. Run 'cake bake controller help' for more info.");
196:         $this->out("\n\tplugin <name> view\n\t\tbakes view. Run 'cake bake view help' for more info.");
197:         $this->out("");
198:         $this->_stop();
199:     }
200: }
201: ?>
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