Cake\Controller\Component::__construct PHP Method

__construct() public method

Constructor
public __construct ( Cake\Controller\ComponentRegistry $registry, array $config = [] )
$registry Cake\Controller\ComponentRegistry A ComponentRegistry this component can use to lazy load its components
$config array Array of configuration settings.
    public function __construct(ComponentRegistry $registry, array $config = [])
    {
        $this->_registry = $registry;
        $controller = $registry->getController();
        if ($controller) {
            $this->request =& $controller->request;
            $this->response =& $controller->response;
        }
        $this->config($config);
        if (!empty($this->components)) {
            $this->_componentMap = $registry->normalizeArray($this->components);
        }
        $this->initialize($config);
    }

Usage Example

 public function __construct(ComponentCollection $collection, $settings = array())
 {
     parent::__construct($collection, $settings);
     // initialize callback urls
     $router = new Router();
     $baseurl = $router->url('/', true);
     $this->controller = $collection->getController();
     $this->http = new Client();
     // Load in PHP extension ZIP...?
     if (extension_loaded('zip') == true) {
         $this->zip = new ZipArchive();
         $this->Controller = $collection->getController();
     } else {
         throw new MissingComponentException(__('Error: Not Load extension "ZIP" in PHP.INI!!'));
     }
     $this->controller->loadModel('EmailTemplates');
     $this->EmailTemplates = $this->controller->EmailTemplates;
     /*
     
      // prefetch partner details
      $this->Partners = $this->controller->Partners;        
      $this->partner_id = $this->controller->Auth->user('partner_id');
      $this->partner = $this->Partners->get($this->partner_id);
      // end prefetch
     */
 }
All Usage Examples Of Cake\Controller\Component::__construct