Cake\Controller\Controller::components PHP Метод

components() публичный Метод

If called with the first parameter, it will be set as the controller $this->_components property
public components ( Cake\Controller\ComponentRegistry | null $components = null ) : Cake\Controller\ComponentRegistry
$components Cake\Controller\ComponentRegistry | null Component registry.
Результат Cake\Controller\ComponentRegistry
    public function components($components = null)
    {
        if ($components === null && $this->_components === null) {
            $this->_components = new ComponentRegistry($this);
        }
        if ($components !== null) {
            $components->setController($this);
            $this->_components = $components;
        }
        return $this->_components;
    }

Usage Example

 /**
  * Returns the test controller
  *
  * @param \Cake\Network\Request $request Request object
  * @param \Cake\Network\Response $response Response for the controller.
  * @return \Cake\Controller\Controller
  */
 protected function _getController($request, $response)
 {
     if ($this->testController === null) {
         $this->testController = parent::_getController($request, $response);
     }
     $default = array('InterceptContent' => array('className' => 'Cake\\TestSuite\\InterceptContentHelper'));
     $this->testController->helpers = array_merge($default, $this->testController->helpers);
     $this->testController->setRequest($request);
     $this->testController->response = $this->response;
     $registry = $this->testController->components();
     foreach ($registry->loaded() as $component) {
         $object = $registry->{$component};
         if (isset($object->response)) {
             $object->response = $response;
         }
         if (isset($object->request)) {
             $object->request = $request;
         }
     }
     return $this->testController;
 }
All Usage Examples Of Cake\Controller\Controller::components