本文整理汇总了PHP中Cake\Controller\Component::__construct方法的典型用法代码示例。如果您正苦于以下问题:PHP Component::__construct方法的具体用法?PHP Component::__construct怎么用?PHP Component::__construct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cake\Controller\Component
的用法示例。
在下文中一共展示了Component::__construct方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
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
*/
}
示例2: __construct
/**
* Constructor.
*
* @param \Cake\Controller\ComponentRegistry $collection
* @param array $config
*/
public function __construct(ComponentRegistry $collection, $config = [])
{
$this->Controller = $collection->getController();
$defaults = (array) Configure::read('Ajax') + $this->_defaultConfig;
$config += $defaults;
parent::__construct($collection, $config);
}
示例3: __construct
/**
* Constructor
*
* @param \Cake\Controller\ComponentRegistry $collection Component Registry
* @param array $config Array of configuration settings.
*/
public function __construct(ComponentRegistry $collection, $config = [])
{
$this->_controller = $collection->getController();
$this->_eventManager = $this->_controller->eventManager();
parent::__construct($collection, $config);
$this->_createCrudComponentInstance();
}
示例4: __construct
/**
* Constructor
*
* @param ComponentRegistry $registry A ComponentRegistry object.
* @param array $config Array of configuration settings.
*/
public function __construct(ComponentRegistry $registry, array $config = [])
{
parent::__construct($registry, $config);
if ($registry->getController() instanceof \Cake\Controller\Controller) {
$this->_controller = $registry->getController();
}
}
示例5: __construct
/**
* Constructor
*
* @param \Cake\Controller\ComponentRegistry $collection
* @param array $config Config options array
*/
public function __construct(ComponentRegistry $collection, $config = [])
{
parent::__construct($collection, $config);
$Controller = $collection->getController();
$this->request = $Controller->request;
$this->response = $Controller->response;
}
示例6: __construct
/**
* Component constructor.
*
* @param ComponentRegistry $registry
* @param array $config
*/
public function __construct(ComponentRegistry $registry, array $config = [])
{
parent::__construct($registry, $config);
if ($controller = $registry->getController()) {
$this->_controller = $controller;
}
}
示例7: __construct
/**
* Constructor. Parses the accepted content types accepted by the client using HTTP_ACCEPT
*
* @param ComponentRegistry $registry ComponentRegistry object.
* @param array $config Config options array
*/
public function __construct(ComponentRegistry $registry, $config = [])
{
$this->_defaultConfig = Hash::merge($this->_defaultConfig, $this->_translateConfigMessages(), (array) Configure::read('UserTools.Component'));
$this->_controller = $registry->getController();
$this->response = $this->_controller->response;
parent::__construct($registry, $config);
}
示例8: __construct
/**
* Constructor
*
* @param ComponentRegistry $registry A ComponentRegistry object.
* @param array $config Array of configuration settings.
*/
public function __construct(ComponentRegistry $registry, array $config = [])
{
parent::__construct($registry, $config);
if ($registry->getController() instanceof \Cake\Controller\Controller) {
$this->_session = $registry->getController()->request->session();
}
$facebookConfig = Configure::read('Facebook');
FacebookSession::setDefaultApplication($facebookConfig['app_id'], $facebookConfig['app_secret']);
}
示例9: __construct
public function __construct(ComponentRegistry $collection, array $config = array())
{
parent::__construct($collection, $config);
$this->controller = $collection->getController();
/*
* Register event listener in the constructor (and not in the startup() method)
* to ensure the listener is set when code in Controller->beforeFilter() is executed
* (startup() is called after Controller->beforeFilter())
*/
$this->listenToModelBeforeSave();
}
示例10: __construct
/**
* Constructor. Will return an instance of the correct ACL class as defined in `Configure::read('Acl.classname')`
*
* @param ComponentRegistry $collection A ComponentRegistry
* @param array $config Array of configuration settings
* @throws \Cake\Error\Exception when Acl.classname could not be loaded.
*/
public function __construct(ComponentRegistry $collection, array $config = array())
{
parent::__construct($collection, $config);
$className = $name = Configure::read('Acl.classname');
if (!class_exists($className)) {
$className = App::className('Acl.' . $name, 'Adapter');
if (!$className) {
throw new Error\Exception(sprintf('Could not find %s.', $name));
}
}
$this->adapter($className);
}
示例11: __construct
public function __construct(&$controller, $settings = array())
{
parent::__construct($controller, $settings);
if (isset($settings['skipAuthCheck'])) {
$this->skipAuthCheck = $settings['skipAuthCheck'];
}
if (!empty($settings['exclude_check_on'])) {
foreach ($settings['exclude_check_on'] as $exclude_check_on) {
$this->_excludeCheckOnList[] = $exclude_check_on;
}
}
$this->secret = Configure::read('shared_secret');
$this->api_key = Configure::read('api_key');
$this->scope = Configure::read('scope');
}
示例12: __construct
public function __construct(ComponentRegistry $collection, array $config = array())
{
parent::__construct($collection, $config);
// initialize callback urls
$router = new Router();
$baseurl = $router->url('/', true);
$this->callback_url = $baseurl . 'external_apps/salesforce/callback';
//end
$this->controller = $collection->getController();
$this->http = new Client();
$this->controller->loadModel('Vendors');
// prefetch vendor details
$this->Vendors = $this->controller->Vendors;
$this->vendor_id = $this->controller->Auth->user('vendor_id');
$this->vendor = $this->Vendors->get($this->vendor_id);
// end prefetch
}
示例13: __construct
/**
* Class constructor
*
* @param Cake\Controller\ComponentRegistry $collection ComponentRegistry instance.
* @param array $config Configuration options
* @return void
*/
public function __construct(\Cake\Controller\ComponentRegistry $collection, array $config)
{
pr("AppPlusPlus __construct()");
// make calling controller available
$this->_controller = $collection->getController();
// Enable Authentication if needed
if ($this->Config('Authentication.enabled')) {
$this->setupAuth();
}
// Load components for the calling calling controller
$this->_controller->loadComponent('RequestHandler');
$this->_controller->loadComponent('Flash');
$this->_controller->loadComponent('Crud.Crud', ['actions' => ['Crud.Index', 'Crud.Add', 'Crud.Edit', 'Crud.View', 'Crud.Delete'], 'listeners' => ['Crud.Api', 'Crud.ApiPagination', 'Crud.ApiQueryLog']]);
$this->_controller->loadComponent('Paginator', ['settings' => ['page' => 1, 'limit' => 25, 'maxLimit' => 100, 'whitelist' => ['limit', 'sort', 'page', 'direction']]]);
//$this->_eventManager = $this->_controller->eventManager();
parent::__construct($collection, $config);
}
示例14: __construct
public function __construct(ComponentRegistry $collection, array $config = array())
{
parent::__construct($collection, $config);
// initialize callback urls
$router = new Router();
$baseurl = $router->url('/', true);
$this->facebook['callback_url'] = $baseurl . 'social_apps/facebook/callback';
$this->twitter['callback_url'] = $baseurl . 'social_apps/twitter/callback';
$this->linkedin['callback_url'] = $baseurl . 'social_apps/linkedin/callback';
//end
$this->controller = $collection->getController();
$this->http = new Client();
FacebookSession::setDefaultApplication($this->facebook['appID'], $this->facebook['appSecret']);
$this->controller->loadModel('Partners');
// 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
}
示例15: __construct
/**
* Constructor
*
* @param \Cake\Controller\ComponentRegistry $collection A ComponentCollection this component
* can use to lazy load its components.
* @param array $config Array of configuration settings.
*/
public function __construct(ComponentRegistry $collection, $config = [])
{
$config += ['actions' => [], 'listeners' => []];
$config['actions'] = $this->normalizeArray($config['actions']);
$config['listeners'] = $this->normalizeArray($config['listeners']);
$this->_controller = $collection->getController();
$this->_eventManager = $this->_controller->eventManager();
parent::__construct($collection, $config);
}