本文整理汇总了PHP中Cake\Controller\Component类的典型用法代码示例。如果您正苦于以下问题:PHP Component类的具体用法?PHP Component怎么用?PHP Component使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Component类的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: initialize
/**
* initialize
*
* @param array $config Config.
* @return void
*/
public function initialize(array $config)
{
parent::initialize($config);
$this->setController($this->_registry->getController());
// adding request handler
$this->Controller->loadComponent('RequestHandler');
// accepts json
$this->Controller->RequestHandler->renderAs($this->Controller, 'json');
// set the default modelName
if (is_null($this->config('modelName'))) {
$this->config('modelName', $this->Controller->name);
}
if (Configure::read('Api.JWT')) {
if ($this->Controller->Auth) {
$this->Controller->Auth->config('authenticate', ['ADmad/JwtAuth.Jwt' => ['parameter' => '_token', 'userModel' => 'Users.Users', 'scope' => ['Users.active' => 1], 'fields' => ['id' => 'id']]]);
}
}
}
示例3: initialize
/**
* Initialize method
*
* @param Component $component Component instance.
* @return void
*/
public function initialize(Component $component)
{
$adapter = $component->config('adapter');
if (is_array($adapter)) {
$this->options = $adapter + $this->options;
}
$engine = new IniConfig(dirname($this->options['config']) . DS);
$this->options = $engine->read(basename($this->options['config']));
}
示例4: initialize
/**
* Initialize method
*
* @param Component $Component Component instance
* @return void
*/
public function initialize(Component $Component)
{
$adapter = $Component->config('adapter');
if (is_array($adapter)) {
$this->options = $adapter + $this->options;
}
$engine = new PhpConfig(dirname($this->options['config']) . DS);
$config = $engine->read(basename($this->options['config']));
$this->build($config);
$Component->Aco = $this->Aco;
$Component->Aro = $this->Aro;
}
示例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
/**
* 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);
}
示例7: __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();
}
}
示例8: initialize
/**
* initialize
*
* Initialize callback for Components.
*
* @param array $config Configurations.
* @return void
*/
public function initialize(array $config)
{
parent::initialize($config);
$this->Controller = $this->_registry->getController();
// set up the default helper
$this->Controller->helpers['Utils.Menu'] = [];
}
示例9: __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();
}
示例10: __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;
}
}
示例11: __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);
}
示例12: initialize
/**
* Initialize Callback
*
* @param array $config
*/
public function initialize(array $config)
{
parent::initialize($config);
$this->Controller = $this->_registry->getController();
if ($this->config('Auth')) {
$this->Controller->loadComponent('Auth', $this->config('Auth'));
}
$this->Controller->loadComponent('Utils.Menu');
}
示例13: __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']);
}
示例14: __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();
}
示例15: initialize
/**
* initialize method
* @param array $config The config data
* @return void
*/
public function initialize(array $config)
{
parent::initialize($config);
if (Configure::read('Users.GoogleAuthenticator.login')) {
$this->tfa = new TwoFactorAuth(Configure::read('Users.GoogleAuthenticator.issuer'), Configure::read('Users.GoogleAuthenticator.digits'), Configure::read('Users.GoogleAuthenticator.period'), Configure::read('Users.GoogleAuthenticator.algorithm'), Configure::read('Users.GoogleAuthenticator.qrcodeprovider'), Configure::read('Users.GoogleAuthenticator.rngprovider'), Configure::read('Users.GoogleAuthenticator.encryptionKey'));
}
}