CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Team
    • Issues (Github)
    • YouTube Channel
    • Get Involved
    • Bakery
    • Featured Resources
    • Newsletter
    • Certification
    • My CakePHP
    • CakeFest
    • Facebook
    • Twitter
    • Help & Support
    • Forum
    • Stack Overflow
    • IRC
    • Slack
    • Paid Support
CakePHP

C CakePHP 3.7 Red Velvet API

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

Namespaces

  • Cake
    • Auth
      • Storage
    • Cache
      • Engine
    • Collection
      • Iterator
    • Command
    • Console
      • Exception
    • Controller
      • Component
      • Exception
    • Core
      • Configure
        • Engine
      • Exception
      • Retry
    • Database
      • Driver
      • Exception
      • Expression
      • Schema
      • Statement
      • Type
    • Datasource
      • Exception
    • Error
      • Middleware
    • Event
      • Decorator
    • Filesystem
    • Form
    • Http
      • Client
        • Adapter
        • Auth
      • Cookie
      • Exception
      • Middleware
      • Session
    • I18n
      • Formatter
      • Middleware
      • Parser
    • Log
      • Engine
    • Mailer
      • Exception
      • Transport
    • Network
      • Exception
    • ORM
      • Association
      • Behavior
        • Translate
      • Exception
      • Locator
      • Rule
    • Routing
      • Exception
      • Filter
      • Middleware
      • Route
    • Shell
      • Helper
      • Task
    • TestSuite
      • Fixture
      • Stub
    • Utility
      • Exception
    • Validation
    • View
      • Exception
      • Form
      • Helper
      • Widget
  • None

Classes

  • Component
  • ComponentRegistry
  • Controller
  • ErrorController
  1: <?php
  2: /**
  3:  * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
  4:  * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
  5:  *
  6:  * Licensed under The MIT License
  7:  * For full copyright and license information, please see the LICENSE.txt
  8:  * Redistributions of files must retain the above copyright notice.
  9:  *
 10:  * @copyright     Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
 11:  * @link          https://cakephp.org CakePHP(tm) Project
 12:  * @since         2.0.0
 13:  * @license       https://opensource.org/licenses/mit-license.php MIT License
 14:  */
 15: namespace Cake\Controller;
 16: 
 17: use Cake\Controller\Exception\MissingComponentException;
 18: use Cake\Core\App;
 19: use Cake\Core\ObjectRegistry;
 20: use Cake\Event\EventDispatcherInterface;
 21: use Cake\Event\EventDispatcherTrait;
 22: 
 23: /**
 24:  * ComponentRegistry is a registry for loaded components
 25:  *
 26:  * Handles loading, constructing and binding events for component class objects.
 27:  */
 28: class ComponentRegistry extends ObjectRegistry implements EventDispatcherInterface
 29: {
 30: 
 31:     use EventDispatcherTrait;
 32: 
 33:     /**
 34:      * The controller that this collection was initialized with.
 35:      *
 36:      * @var \Cake\Controller\Controller
 37:      */
 38:     protected $_Controller;
 39: 
 40:     /**
 41:      * Constructor.
 42:      *
 43:      * @param \Cake\Controller\Controller|null $controller Controller instance.
 44:      */
 45:     public function __construct(Controller $controller = null)
 46:     {
 47:         if ($controller) {
 48:             $this->setController($controller);
 49:         }
 50:     }
 51: 
 52:     /**
 53:      * Get the controller associated with the collection.
 54:      *
 55:      * @return \Cake\Controller\Controller Controller instance
 56:      */
 57:     public function getController()
 58:     {
 59:         return $this->_Controller;
 60:     }
 61: 
 62:     /**
 63:      * Set the controller associated with the collection.
 64:      *
 65:      * @param \Cake\Controller\Controller $controller Controller instance.
 66:      * @return void
 67:      */
 68:     public function setController(Controller $controller)
 69:     {
 70:         $this->_Controller = $controller;
 71:         $this->setEventManager($controller->getEventManager());
 72:     }
 73: 
 74:     /**
 75:      * Resolve a component classname.
 76:      *
 77:      * Part of the template method for Cake\Core\ObjectRegistry::load()
 78:      *
 79:      * @param string $class Partial classname to resolve.
 80:      * @return string|false Either the correct classname or false.
 81:      */
 82:     protected function _resolveClassName($class)
 83:     {
 84:         return App::className($class, 'Controller/Component', 'Component');
 85:     }
 86: 
 87:     /**
 88:      * Throws an exception when a component is missing.
 89:      *
 90:      * Part of the template method for Cake\Core\ObjectRegistry::load()
 91:      * and Cake\Core\ObjectRegistry::unload()
 92:      *
 93:      * @param string $class The classname that is missing.
 94:      * @param string $plugin The plugin the component is missing in.
 95:      * @return void
 96:      * @throws \Cake\Controller\Exception\MissingComponentException
 97:      */
 98:     protected function _throwMissingClassError($class, $plugin)
 99:     {
100:         throw new MissingComponentException([
101:             'class' => $class . 'Component',
102:             'plugin' => $plugin
103:         ]);
104:     }
105: 
106:     /**
107:      * Create the component instance.
108:      *
109:      * Part of the template method for Cake\Core\ObjectRegistry::load()
110:      * Enabled components will be registered with the event manager.
111:      *
112:      * @param string $class The classname to create.
113:      * @param string $alias The alias of the component.
114:      * @param array $config An array of config to use for the component.
115:      * @return \Cake\Controller\Component The constructed component class.
116:      */
117:     protected function _create($class, $alias, $config)
118:     {
119:         $instance = new $class($this, $config);
120:         $enable = isset($config['enabled']) ? $config['enabled'] : true;
121:         if ($enable) {
122:             $this->getEventManager()->on($instance);
123:         }
124: 
125:         return $instance;
126:     }
127: }
128: 
Follow @CakePHP
#IRC
OpenHub
Rackspace
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Logos & Trademarks
  • Community
  • Team
  • Issues (Github)
  • YouTube Channel
  • Get Involved
  • Bakery
  • Featured Resources
  • Newsletter
  • Certification
  • My CakePHP
  • CakeFest
  • Facebook
  • Twitter
  • Help & Support
  • Forum
  • Stack Overflow
  • IRC
  • Slack
  • Paid Support

Generated using CakePHP API Docs