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:  * API shell to get CakePHP core method signatures.
  5:  *
  6:  * Implementation of a Cake Shell to show CakePHP core method signatures.
  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
 20:  * @since         CakePHP(tm) v 1.2.0.5012
 21:  * @version       $Revision$
 22:  * @modifiedby    $LastChangedBy$
 23:  * @lastmodified  $Date$
 24:  * @license       http://www.opensource.org/licenses/mit-license.php The MIT License
 25:  */
 26: 
 27: /**
 28:  * API shell to show method signatures of CakePHP core classes.
 29:  *
 30:  * @package       cake
 31:  * @subpackage    cake.cake.console.libs
 32:  */
 33: class ApiShell extends Shell {
 34: /**
 35:  * Map between short name for paths and real paths.
 36:  *
 37:  * @var array
 38:  * @access public
 39:  */
 40:     var $paths = array();
 41: /**
 42:  * Override intialize of the Shell
 43:  *
 44:  * @access public
 45:  */
 46:     function initialize () {
 47:         $this->paths = array_merge($this->paths, array(
 48:             'behavior' => LIBS . 'model' . DS . 'behaviors' . DS,
 49:             'cache' => LIBS . 'cache' . DS,
 50:             'controller' => LIBS . 'controller' . DS,
 51:             'component' => LIBS . 'controller' . DS . 'components' . DS,
 52:             'helper' => LIBS . 'view' . DS . 'helpers' . DS,
 53:             'model' => LIBS . 'model' . DS,
 54:             'view' => LIBS . 'view' . DS,
 55:             'core' => LIBS
 56:         ));
 57:     }
 58: /**
 59:  * Override main() to handle action
 60:  *
 61:  * @access public
 62:  */
 63:     function main() {
 64:         if (empty($this->args)) {
 65:             return $this->help();
 66:         }
 67: 
 68:         $type = strtolower($this->args[0]);
 69: 
 70:         if (isset($this->paths[$type])) {
 71:             $path = $this->paths[$type];
 72:         } else {
 73:             $path = $this->paths['core'];
 74:         }
 75: 
 76:         if (count($this->args) == 1) {
 77:             $file = $type;
 78:             $class = Inflector::camelize($type);
 79:         } elseif (count($this->args) > 1) {
 80:             $file = Inflector::underscore($this->args[1]);
 81:             $class = Inflector::camelize($file);
 82:         }
 83: 
 84:         $objects = Configure::listObjects('class', $path);
 85:         if (in_array($class, $objects)) {
 86:             if (in_array($type, array('behavior', 'component', 'helper')) && $type !== $file) {
 87:                 if (!preg_match('/' . Inflector::camelize($type) . '$/', $class)) {
 88:                     $class .= Inflector::camelize($type);
 89:                 }
 90:             }
 91: 
 92:         } else {
 93:             $this->err(sprintf(__("%s not found", true), $class));
 94:             $this->_stop();
 95:         }
 96: 
 97:         $parsed = $this->__parseClass($path . $file .'.php');
 98: 
 99:         if (!empty($parsed)) {
100:             if (isset($this->params['m'])) {
101:                 if (!isset($parsed[$this->params['m']])) {
102:                     $this->err(sprintf(__("%s::%s() could not be found", true), $class, $this->params['m']));
103:                     $this->_stop();
104:                 }
105:                 $method = $parsed[$this->params['m']];
106:                 $this->out($class .'::'.$method['method'] . $method['parameters']);
107:                 $this->hr();
108:                 $this->out($method['comment'], true);
109:             } else {
110:                 $this->out(ucwords($class));
111:                 $this->hr();
112:                 $i = 0;
113:                 foreach ($parsed as $method) {
114:                     $list[] = ++$i . ". " . $method['method'] . $method['parameters'];
115:                 }
116:                 $this->out($list);
117: 
118:                 $methods = array_keys($parsed);
119:                 while ($number = strtolower($this->in(__('Select a number to see the more information about a specific method. q to quit. l to list.', true), null, 'q'))) {
120:                     if ($number === 'q') {
121:                         $this->out(__('Done', true));
122:                         $this->_stop();
123:                     }
124: 
125:                     if ($number === 'l') {
126:                         $this->out($list);
127:                     }
128: 
129:                     if (isset($methods[--$number])) {
130:                         $method = $parsed[$methods[$number]];
131:                         $this->hr();
132:                         $this->out($class .'::'.$method['method'] . $method['parameters']);
133:                         $this->hr();
134:                         $this->out($method['comment'], true);
135:                     }
136:                 }
137:             }
138:         }
139:     }
140: 
141: /**
142:  * Show help for this shell.
143:  *
144:  * @access public
145:  */
146:     function help() {
147:         $head  = "Usage: cake api [<type>] <className> [-m <method>]\n";
148:         $head .= "-----------------------------------------------\n";
149:         $head .= "Parameters:\n\n";
150: 
151:         $commands = array(
152:             'path' => "\t<type>\n" .
153:                 "\t\tEither a full path or type of class (model, behavior, controller, component, view, helper).\n".
154:                 "\t\tAvailable values:\n\n".
155:                 "\t\tbehavior\tLook for class in CakePHP behavior path\n".
156:                 "\t\tcache\tLook for class in CakePHP cache path\n".
157:                 "\t\tcontroller\tLook for class in CakePHP controller path\n".
158:                 "\t\tcomponent\tLook for class in CakePHP component path\n".
159:                 "\t\thelper\tLook for class in CakePHP helper path\n".
160:                 "\t\tmodel\tLook for class in CakePHP model path\n".
161:                 "\t\tview\tLook for class in CakePHP view path\n",
162:             'className' => "\t<className>\n" .
163:                 "\t\tA CakePHP core class name (e.g: Component, HtmlHelper).\n"
164:         );
165: 
166:         $this->out($head);
167:         if (!isset($this->args[1])) {
168:             foreach ($commands as $cmd) {
169:                 $this->out("{$cmd}\n\n");
170:             }
171:         } elseif (isset($commands[strtolower($this->args[1])])) {
172:             $this->out($commands[strtolower($this->args[1])] . "\n\n");
173:         } else {
174:             $this->out("Command '" . $this->args[1] . "' not found");
175:         }
176:     }
177: 
178: /**
179:  * Parse a given class (located on given file) and get public methods and their
180:  * signatures.
181:  *
182:  * @param object $File File object
183:  * @param string $class Class name
184:  * @return array Methods and signatures indexed by method name
185:  * @access private
186:  */
187:     function __parseClass($path) {
188:         $parsed = array();
189: 
190:         $File = new File($path);
191:         if (!$File->exists()) {
192:             $this->err(sprintf(__("%s could not be found", true), $File->name));
193:             $this->_stop();
194:         }
195: 
196:         $contents = $File->read();
197: 
198:         if (preg_match_all('%(/\\*\\*[\\s\\S]*?\\*/)(\\s+function\\s+\\w+)(\\(.*\\))%', $contents, $result, PREG_PATTERN_ORDER)) {
199:             foreach ($result[2] as $key => $method) {
200:                 $method = str_replace('function ', '', trim($method));
201: 
202:                 if (strpos($method, '__') === false && $method[0] != '_') {
203:                     $parsed[$method] = array(
204:                         'comment' => str_replace(array('/*', '*/', '*'), '', trim($result[1][$key])),
205:                         'method' => $method,
206:                         'parameters' => trim($result[3][$key])
207:                     );
208:                 }
209:             }
210:         }
211:         ksort($parsed);
212:         return $parsed;
213:     }
214: }
215: ?>
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