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:  * Command-line code generation utility to automate programmer chores.
  5:  *
  6:  * Bake is CakePHP's code generation script, which can help you kickstart
  7:  * application development by writing fully functional skeleton controllers,
  8:  * models, and views. Going further, Bake can also write Unit Tests for you.
  9:  *
 10:  * PHP versions 4 and 5
 11:  *
 12:  * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
 13:  * Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
 14:  *
 15:  * Licensed under The MIT License
 16:  * Redistributions of files must retain the above copyright notice.
 17:  *
 18:  * @copyright     Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
 19:  * @link          http://cakephp.org CakePHP(tm) Project
 20:  * @package       cake
 21:  * @subpackage    cake.cake.console.libs
 22:  * @since         CakePHP(tm) v 1.2.0.5012
 23:  * @version       $Revision$
 24:  * @modifiedby    $LastChangedBy$
 25:  * @lastmodified  $Date$
 26:  * @license       http://www.opensource.org/licenses/mit-license.php The MIT License
 27:  */
 28: /**
 29:  * Bake is a command-line code generation utility for automating programmer chores.
 30:  *
 31:  * @package       cake
 32:  * @subpackage    cake.cake.console.libs
 33:  * @link          http://book.cakephp.org/view/113/Code-Generation-with-Bake
 34:  */
 35: class BakeShell extends Shell {
 36: /**
 37:  * Contains tasks to load and instantiate
 38:  *
 39:  * @var array
 40:  * @access public
 41:  */
 42:     var $tasks = array('Project', 'DbConfig', 'Model', 'Controller', 'View', 'Plugin', 'Test');
 43: /**
 44:  * Override loadTasks() to handle paths
 45:  *
 46:  * @access public
 47:  */
 48:     function loadTasks() {
 49:         parent::loadTasks();
 50:         $task = Inflector::classify($this->command);
 51:         if (isset($this->{$task}) && !in_array($task, array('Project', 'DbConfig'))) {
 52:             $path = Inflector::underscore(Inflector::pluralize($this->command));
 53:             $this->{$task}->path = $this->params['working'] . DS . $path . DS;
 54:             if (!is_dir($this->{$task}->path)) {
 55:                 $this->err(sprintf(__("%s directory could not be found.\nBe sure you have created %s", true), $task, $this->{$task}->path));
 56:                 $this->_stop();
 57:             }
 58:         }
 59:     }
 60: /**
 61:  * Override main() to handle action
 62:  *
 63:  * @access public
 64:  */
 65:     function main() {
 66:         if (!is_dir($this->DbConfig->path)) {
 67:             if ($this->Project->execute()) {
 68:                 $this->DbConfig->path = $this->params['working'] . DS . 'config' . DS;
 69:             }
 70:         }
 71: 
 72:         if (!config('database')) {
 73:             $this->out(__("Your database configuration was not found. Take a moment to create one.", true));
 74:             $this->args = null;
 75:             return $this->DbConfig->execute();
 76:         }
 77:         $this->out('Interactive Bake Shell');
 78:         $this->hr();
 79:         $this->out('[D]atabase Configuration');
 80:         $this->out('[M]odel');
 81:         $this->out('[V]iew');
 82:         $this->out('[C]ontroller');
 83:         $this->out('[P]roject');
 84:         $this->out('[Q]uit');
 85: 
 86:         $classToBake = strtoupper($this->in(__('What would you like to Bake?', true), array('D', 'M', 'V', 'C', 'P', 'Q')));
 87:         switch ($classToBake) {
 88:             case 'D':
 89:                 $this->DbConfig->execute();
 90:                 break;
 91:             case 'M':
 92:                 $this->Model->execute();
 93:                 break;
 94:             case 'V':
 95:                 $this->View->execute();
 96:                 break;
 97:             case 'C':
 98:                 $this->Controller->execute();
 99:                 break;
100:             case 'P':
101:                 $this->Project->execute();
102:                 break;
103:             case 'Q':
104:                 exit(0);
105:                 break;
106:             default:
107:                 $this->out(__('You have made an invalid selection. Please choose a type of class to Bake by entering D, M, V, or C.', true));
108:         }
109:         $this->hr();
110:         $this->main();
111:     }
112: /**
113:  * Quickly bake the MVC
114:  *
115:  * @access public
116:  */
117:     function all() {
118:         $ds = 'default';
119:         $this->hr();
120:         $this->out('Bake All');
121:         $this->hr();
122: 
123:         if (isset($this->params['connection'])) {
124:             $ds = $this->params['connection'];
125:         }
126: 
127:         if (empty($this->args)) {
128:             $name = $this->Model->getName($ds);
129:         }
130: 
131:         if (!empty($this->args[0])) {
132:             $name = $this->args[0];
133:             $this->Model->listAll($ds, false);
134:         }
135: 
136:         $modelExists = false;
137:         $model = $this->_modelName($name);
138:         if (App::import('Model', $model)) {
139:             $object = new $model();
140:             $modelExists = true;
141:         } else {
142:             App::import('Model');
143:             $object = new Model(array('name' => $name, 'ds' => $ds));
144:         }
145: 
146:         $modelBaked = $this->Model->bake($object, false);
147: 
148:         if ($modelBaked && $modelExists === false) {
149:             $this->out(sprintf(__('%s Model was baked.', true), $model));
150:             if ($this->_checkUnitTest()) {
151:                 $this->Model->bakeTest($model);
152:             }
153:             $modelExists = true;
154:         }
155: 
156:         if ($modelExists === true) {
157:             $controller = $this->_controllerName($name);
158:             if ($this->Controller->bake($controller, $this->Controller->bakeActions($controller))) {
159:                 $this->out(sprintf(__('%s Controller was baked.', true), $name));
160:                 if ($this->_checkUnitTest()) {
161:                     $this->Controller->bakeTest($controller);
162:                 }
163:             }
164:             if (App::import('Controller', $controller)) {
165:                 $this->View->args = array($controller);
166:                 $this->View->execute();
167:             }
168:             $this->out(__('Bake All complete'));
169:             array_shift($this->args);
170:         } else {
171:             $this->err(__('Bake All could not continue without a valid model', true));
172:         }
173: 
174:         if (empty($this->args)) {
175:             $this->all();
176:         }
177:         $this->_stop();
178:     }
179: 
180: /**
181:  * Displays help contents
182:  *
183:  * @access public
184:  */
185:     function help() {
186:         $this->out('CakePHP Bake:');
187:         $this->hr();
188:         $this->out('The Bake script generates controllers, views and models for your application.');
189:         $this->out('If run with no command line arguments, Bake guides the user through the class');
190:         $this->out('creation process. You can customize the generation process by telling Bake');
191:         $this->out('where different parts of your application are using command line arguments.');
192:         $this->hr();
193:         $this->out("Usage: cake bake <command> <arg1> <arg2>...");
194:         $this->hr();
195:         $this->out('Params:');
196:         $this->out("\t-app <path> Absolute/Relative path to your app folder.\n");
197:         $this->out('Commands:');
198:         $this->out("\n\tbake help\n\t\tshows this help message.");
199:         $this->out("\n\tbake all <name>\n\t\tbakes complete MVC. optional <name> of a Model");
200:         $this->out("\n\tbake project <path>\n\t\tbakes a new app folder in the path supplied\n\t\tor in current directory if no path is specified");
201:         $this->out("\n\tbake plugin <name>\n\t\tbakes a new plugin folder in the path supplied\n\t\tor in current directory if no path is specified.");
202:         $this->out("\n\tbake db_config\n\t\tbakes a database.php file in config directory.");
203:         $this->out("\n\tbake model\n\t\tbakes a model. run 'bake model help' for more info");
204:         $this->out("\n\tbake view\n\t\tbakes views. run 'bake view help' for more info");
205:         $this->out("\n\tbake controller\n\t\tbakes a controller. run 'bake controller help' for more info");
206:         $this->out("");
207: 
208:     }
209: }
210: ?>
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