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:  *
  5:  * PHP versions 4 and 5
  6:  *
  7:  * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  8:  * Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
  9:  *
 10:  * Licensed under The MIT License
 11:  * Redistributions of files must retain the above copyright notice.
 12:  *
 13:  * @copyright     Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
 14:  * @link          http://cakephp.org CakePHP(tm) Project
 15:  * @package       cake
 16:  * @subpackage    cake.cake.libs.controller
 17:  * @since         CakePHP(tm) v TBD
 18:  * @version       $Revision$
 19:  * @modifiedby    $LastChangedBy$
 20:  * @lastmodified  $Date$
 21:  * @license       http://www.opensource.org/licenses/mit-license.php The MIT License
 22:  */
 23: /**
 24:  * Handler for Controller::$components
 25:  *
 26:  * @package       cake
 27:  * @subpackage    cake.cake.libs.controller
 28:  * @link          http://book.cakephp.org/view/62/Components
 29:  */
 30: class Component extends Object {
 31: /**
 32:  * Contains various controller variable information (plugin, name, base).
 33:  *
 34:  * @var object
 35:  * @access private
 36:  */
 37:     var $__controllerVars = array('plugin' => null, 'name' => null, 'base' => null);
 38: /**
 39:  * List of loaded components.
 40:  *
 41:  * @var object
 42:  * @access protected
 43:  */
 44:     var $_loaded = array();
 45: /**
 46:  * List of components attached directly to the controller, which callbacks
 47:  * should be executed on.
 48:  *
 49:  * @var object
 50:  * @access protected
 51:  */
 52:     var $_primary = array();
 53: /**
 54:  * Settings for loaded components.
 55:  *
 56:  * @var array
 57:  * @access private
 58:  **/
 59:     var $__settings = array();
 60: /**
 61:  * Used to initialize the components for current controller.
 62:  *
 63:  * @param object $controller Controller with components to load
 64:  * @return void
 65:  * @access public
 66:  */
 67:     function init(&$controller) {
 68:         if (!is_array($controller->components)) {
 69:             return;
 70:         }
 71:         $this->__controllerVars = array(
 72:             'plugin' => $controller->plugin, 'name' => $controller->name,
 73:             'base' => $controller->base
 74:         );
 75: 
 76:         $this->_loadComponents($controller);
 77:     }
 78: /**
 79:  * Called before the Controller::beforeFilter().
 80:  *
 81:  * @param object $controller Controller with components to initialize
 82:  * @return void
 83:  * @access public
 84:  * @link http://book.cakephp.org/view/65/MVC-Class-Access-Within-Components
 85:  */
 86:     function initialize(&$controller) {
 87:         foreach (array_keys($this->_loaded) as $name) {
 88:             $component =& $this->_loaded[$name];
 89: 
 90:             if (method_exists($component,'initialize') && $component->enabled === true) {
 91:                 $settings = array();
 92:                 if (isset($this->__settings[$name])) {
 93:                     $settings = $this->__settings[$name];
 94:                 }
 95:                 $component->initialize($controller, $settings);
 96:             }
 97:         }
 98:     }
 99: /**
100:  * Called after the Controller::beforeFilter() and before the controller action
101:  *
102:  * @param object $controller Controller with components to startup
103:  * @return void
104:  * @access public
105:  * @link http://book.cakephp.org/view/65/MVC-Class-Access-Within-Components
106:  */
107:     function startup(&$controller) {
108:         foreach ($this->_primary as $name) {
109:             $component =& $this->_loaded[$name];
110:             if ($component->enabled === true && method_exists($component, 'startup')) {
111:                 $component->startup($controller);
112:             }
113:         }
114:     }
115: /**
116:  * Called after the Controller::beforeRender(), after the view class is loaded, and before the
117:  * Controller::render()
118:  *
119:  * @param object $controller Controller with components to beforeRender
120:  * @return void
121:  * @access public
122:  */
123:     function beforeRender(&$controller) {
124:         foreach ($this->_primary as $name) {
125:             $component =& $this->_loaded[$name];
126:             if ($component->enabled === true && method_exists($component,'beforeRender')) {
127:                 $component->beforeRender($controller);
128:             }
129:         }
130:     }
131: /**
132:  * Called before Controller::redirect().
133:  *
134:  * @param object $controller Controller with components to beforeRedirect
135:  * @return void
136:  * @access public
137:  */
138:     function beforeRedirect(&$controller, $url, $status = null, $exit = true) {
139:         $response = array();
140: 
141:         foreach ($this->_primary as $name) {
142:             $component =& $this->_loaded[$name];
143: 
144:             if ($component->enabled === true && method_exists($component, 'beforeRedirect')) {
145:                 $resp = $component->beforeRedirect($controller, $url, $status, $exit);
146:                 if ($resp === false) {
147:                     return false;
148:                 }
149:                 $response[] = $resp;
150:             }
151:         }
152:         return $response;
153:     }
154: /**
155:  * Called after Controller::render() and before the output is printed to the browser.
156:  *
157:  * @param object $controller Controller with components to shutdown
158:  * @return void
159:  * @access public
160:  */
161:     function shutdown(&$controller) {
162:         foreach ($this->_primary as $name) {
163:             $component =& $this->_loaded[$name];
164:             if (method_exists($component,'shutdown') && $component->enabled === true) {
165:                 $component->shutdown($controller);
166:             }
167:         }
168:     }
169: /**
170:  * Loads components used by this component.
171:  *
172:  * @param object $object Object with a Components array
173:  * @param object $parent the parent of the current object
174:  * @return void
175:  * @access protected
176:  */
177:     function _loadComponents(&$object, $parent = null) {
178:         $base = $this->__controllerVars['base'];
179:         $normal = Set::normalize($object->components);
180:         if ($parent == null) {
181:             $normal = Set::merge(array('Session' => null), $normal);
182:         }
183:         foreach ((array)$normal as $component => $config) {
184:             $plugin = null;
185: 
186:             if (isset($this->__controllerVars['plugin'])) {
187:                 $plugin = $this->__controllerVars['plugin'] . '.';
188:             }
189: 
190:             if (strpos($component, '.') !== false) {
191:                 list($plugin, $component) = explode('.', $component);
192:                 $plugin = $plugin . '.';
193:             }
194:             $componentCn = $component . 'Component';
195: 
196:             if (!class_exists($componentCn)) {
197:                 if (is_null($plugin) || !App::import('Component', $plugin . $component)) {
198:                     if (!App::import('Component', $component)) {
199:                         $this->cakeError('missingComponentFile', array(array(
200:                             'className' => $this->__controllerVars['name'],
201:                             'component' => $component,
202:                             'file' => Inflector::underscore($component) . '.php',
203:                             'base' => $base,
204:                             'code' => 500
205:                         )));
206:                         return false;
207:                     }
208:                 }
209: 
210:                 if (!class_exists($componentCn)) {
211:                     $this->cakeError('missingComponentClass', array(array(
212:                         'className' => $this->__controllerVars['name'],
213:                         'component' => $component,
214:                         'file' => Inflector::underscore($component) . '.php',
215:                         'base' => $base,
216:                         'code' => 500
217:                     )));
218:                     return false;
219:                 }
220:             }
221: 
222:             if ($parent === null) {
223:                 $this->_primary[] = $component;
224:             }
225: 
226:             if (isset($this->_loaded[$component])) {
227:                 $object->{$component} =& $this->_loaded[$component];
228: 
229:                 if (!empty($config) && isset($this->__settings[$component])) {
230:                     $this->__settings[$component] = array_merge($this->__settings[$component], $config);
231:                 } elseif (!empty($config)) {
232:                     $this->__settings[$component] = $config;
233:                 }
234:             } else {
235:                 if ($componentCn === 'SessionComponent') {
236:                     $object->{$component} =& new $componentCn($base);
237:                 } else {
238:                     $object->{$component} =& new $componentCn();
239:                 }
240:                 $object->{$component}->enabled = true;
241:                 $this->_loaded[$component] =& $object->{$component};
242:                 if (!empty($config)) {
243:                     $this->__settings[$component] = $config;
244:                 }
245:             }
246: 
247:             if (isset($object->{$component}->components) && is_array($object->{$component}->components) && (!isset($object->{$component}->{$parent}))) {
248:                 $this->_loadComponents($object->{$component}, $component);
249:             }
250:         }
251:     }
252: }
253: 
254: ?>
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