當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Controller::loadComponent方法代碼示例

本文整理匯總了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']]]);
         }
     }
 }
開發者ID:jxav,項目名稱:cakephp-api,代碼行數:24,代碼來源:ApiBuilderComponent.php

示例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);
 }
開發者ID:sonuchauhan,項目名稱:cakephp-ratings,代碼行數:22,代碼來源:RatingsComponentTest.php

示例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());
     }
 }
開發者ID:cakeplugins,項目名稱:api,代碼行數:11,代碼來源:ApiBuilderComponent.php

示例4: _setupAuthComponent

 /**
  * Setup Auth component settings
  */
 protected function _setupAuthComponent()
 {
     $this->controller->loadComponent('Auth', Configure::read('Auth'));
 }
開發者ID:mohammadsaleh,項目名稱:spider,代碼行數:7,代碼來源:AclManagerEventHandler.php

示例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);
         }
     }
 }
開發者ID:UnionCMS,項目名稱:Core,代碼行數:16,代碼來源:Hook.php

示例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');
 }
開發者ID:Adnan0703,項目名稱:Xeta,代碼行數:11,代碼來源:Badges.php


注:本文中的Cake\Controller\Controller::loadComponent方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。