本文整理汇总了PHP中Cake\Controller\Controller::loadComponent方法的典型用法代码示例。如果您正苦于以下问题:PHP Controller::loadComponent方法的具体用法?PHP Controller::loadComponent怎么用?PHP Controller::loadComponent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cake\Controller\Controller
的用法示例。
在下文中一共展示了Controller::loadComponent方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: _initControllerAndRatings
/**
* Convenience method for testing: Initializes the controller and the Ratings component
*
* @param array $params Controller params
* @return void
*/
protected function _initControllerAndRatings($params = [])
{
$_default = ['?' => [], 'pass' => []];
$this->Controller->request->params = array_merge($_default, $params);
if (!empty($this->Controller->request->params['?'])) {
$this->Controller->request->query = $this->Controller->request->params['?'];
}
$this->Controller->components()->unload('Ratings');
$options = isset($this->Controller->components['Ratings.Ratings']) ? $this->Controller->components['Ratings.Ratings'] : [];
$this->Controller->loadComponent('Ratings.Ratings', $options);
$event = new Event('beforeFilter', $this->Controller);
$this->Controller->Ratings->beforeFilter($event);
//$this->Controller->Components->trigger('initialize', array(&$this->Controller));
//$this->Controller->Auth = $this->AuthComponent;
//$this->Controller->Ratings->beforeFilter($this->Controller);
}
示例3: _createCrudComponentInstance
/**
* Creates instance of the Crud Component if it doesn't exist yet.
*
* @return void
*/
protected function _createCrudComponentInstance()
{
if (!$this->_registry->has('Crud.Crud')) {
$this->_controller->loadComponent('Crud.Crud', $this->config());
}
}
示例4: _setupAuthComponent
/**
* Setup Auth component settings
*/
protected function _setupAuthComponent()
{
$this->controller->loadComponent('Auth', Configure::read('Auth'));
}
示例5: _loadComponent
/**
* Load controller component by configure.
*
* @param Controller $controller
* @return void
*/
protected static function _loadComponent(Controller $controller)
{
$hooks = self::_getConfigData(Hook::HOOK_CONFIG_COMPONENT_KEY);
foreach ($hooks as $name => $params) {
list($controllers, $config) = self::_createParams($params);
if (self::_inController($controllers, $controller->name)) {
$controller->loadComponent($name, $config);
}
}
}
示例6: __construct
/**
* Construct method.
*
* @param \Cake\Controller\Controller $controller The controller instance where the Event is dispatched.
*
* @return void
*/
public function __construct($controller)
{
$this->Flash = $controller->loadComponent('Flash');
}