本文整理汇总了PHP中Cake\Controller\Component::initialize方法的典型用法代码示例。如果您正苦于以下问题:PHP Component::initialize方法的具体用法?PHP Component::initialize怎么用?PHP Component::initialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cake\Controller\Component
的用法示例。
在下文中一共展示了Component::initialize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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']]]);
}
}
}
示例2: 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'));
}
}
示例3: initialize
/**
* initialize
*
* @param array $config Config.
* @return void
*/
public function initialize(array $config)
{
parent::initialize($config);
$this->Controller = $this->_registry->getController();
$this->Users = TableRegistry::get($this->config('userModel'));
$this->Usermetas = TableRegistry::get($this->config('usermetasModel'));
}
示例4: 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'] = [];
}
示例5: initialize
/**
* Initialize config data and properties.
*
* @param array $config The config data.
* @return void
*/
public function initialize(array $config)
{
parent::initialize($config);
$this->_cookieName = Configure::read('Users.RememberMe.Cookie.name');
$this->_validateConfig();
$this->setCookieOptions();
$this->_attachEvents();
}
示例6: 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');
}
示例7: initialize
public function initialize(array $config)
{
parent::initialize($config);
$this->uid = uniqid();
$this->request_pg = new \PagSeguroPaymentRequest();
$this->request_pg->setShippingType(self::NOT_SPECIFIED);
$this->request_pg->setReference($this->uid);
$this->request_pg->setCurrency('BRL');
}
示例8: initialize
public function initialize(array $config)
{
parent::initialize($config);
$this->_controller = $this->_registry->getController();
$action = $this->_controller->request->param('action');
if (in_array($action, ['edit', 'add'])) {
$this->__setCurrentUserPermissions();
}
}
示例9: initialize
/**
* Initialize method
* @param array $config configuration array
* @return void
*/
public function initialize(array $config)
{
parent::initialize($config);
$this->_controller = $this->_registry->getController();
$this->_user = $this->Auth->user();
$this->_capabilitiesTable = TableRegistry::get('RolesCapabilities.Capabilities');
$this->_capabilitiesTable->setCurrentRequest($config['currentRequest']);
$this->_capabilitiesTable->setCurrentUser($this->Auth->user());
}
示例10: initialize
public function initialize(array $config)
{
parent::initialize($config);
$this->Controller = $this->_registry->getController();
if ($this->request->is('service')) {
$this->service = true;
$this->Controller->viewClass = 'json';
$this->data = [self::SUCCESS_KEY => false, self::CODE_KEY => 0, self::MESSAGE_KEY => 'Default message'];
}
}
示例11: initialize
/**
* Initialize method, setup Auth if not already done passing the $config provided and
* setup the default table to Users.Users if not provided
*
* @param array $config config options
* @return void
*/
public function initialize(array $config)
{
parent::initialize($config);
$this->_validateConfig();
$this->_initAuth();
if (Configure::read('Users.Social.login')) {
$this->_loadSocialLogin();
}
if (Configure::read('Users.RememberMe.active')) {
$this->_loadRememberMe();
}
$this->_attachPermissionChecker();
}
示例12: initialize
public function initialize(array $config)
{
parent::initialize($config);
$privatni = $config['privatni'];
$verejny = $config['verejny'];
$heslo = $config['heslo'];
$fp = fopen($privatni, "r");
$this->privatni = fread($fp, filesize($privatni));
fclose($fp);
$this->heslo = $heslo;
$fp = fopen($verejny, "r");
$this->verejny = fread($fp, filesize($verejny));
fclose($fp);
}
示例13: initialize
public function initialize(array $config)
{
parent::initialize($config);
// if mode is not set in bootstrap, defaults to 'Test'
$mode = Configure::read('Stripe.mode');
if ($mode) {
$this->mode = $mode;
}
// set the Stripe API key
$this->key = Configure::read('Stripe.' . $this->mode . 'Secret');
if (!$this->key) {
throw new Exception('Stripe API Secret key is not set');
}
// if currency is not set, defaults to 'usd'
$currency = Configure::read('Stripe.currency');
if ($currency) {
$this->currency = strtolower($currency);
}
}
示例14: initialize
public function initialize(array $_defaultConfig)
{
parent::initialize($_defaultConfig);
$this->OverviewModel = TableRegistry::get('Overview');
}
示例15: initialize
/**
* initialize
*
* @param array $config Config.
* @return void
*/
public function initialize(array $config)
{
parent::initialize($config);
$this->Controller = $this->_registry->getController();
}