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


PHP AppController::loadComponent方法代碼示例

本文整理匯總了PHP中App\Controller\AppController::loadComponent方法的典型用法代碼示例。如果您正苦於以下問題:PHP AppController::loadComponent方法的具體用法?PHP AppController::loadComponent怎麽用?PHP AppController::loadComponent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在App\Controller\AppController的用法示例。


在下文中一共展示了AppController::loadComponent方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: updateMarked

 public function updateMarked()
 {
     $controller = new AppController();
     $fitbit = $controller->loadComponent('Fitbit');
     $lr_table = TableRegistry::get('LinkedRecords');
     $linked_records = $lr_table->find()->contain('SocialAccounts')->where(['marked_for_update' => 1]);
     foreach ($linked_records as $linked_record) {
         $fitbit->_saveSteps($linked_record->social_account, 'steps', $linked_record->associated_date);
     }
 }
開發者ID:abf6ug,項目名稱:statbro,代碼行數:10,代碼來源:UpdateFitbitRecordsShell.php

示例2: afterCookieLogin

 public function afterCookieLogin($event, $entity, $options = [])
 {
     $controller = new AppController();
     $auth = $controller->loadComponent('Auth');
     $this->_plusPlusCount($auth->user(), 'cookie_login_count');
 }
開發者ID:abf6ug,項目名稱:statbro,代碼行數:6,代碼來源:LoginListener.php

示例3: generateAllFriendActivities

 public function generateAllFriendActivities()
 {
     $controller = new AppController();
     $stream = $controller->loadComponent('Stream');
     $f_table = TableRegistry::get('Friendships');
     $friends = $f_table->find()->where(['status' => 'accepted'])->order(['Friendships.modified' => 'desc'])->all();
     foreach ($friends as $friend) {
         $base_data = $stream->_createStreamData($friend->id, 'Friendship');
         if (!$base_data) {
             continue;
         }
         //            debug($friend->getShortName());
         //            debug($base_data);
         //            if($base_data['game_type_name'] =='Coding')
         //                continue;
         //            debug($base_data);
         //            debug($game->winners);
         //            debug($base_data['display']);
         //            if (!$tm_table->exists(['id'=>$base_data['first_user_id']]))
         $stream->_pushToStream($base_data, $base_data['first_user_id']);
         //            if (!$tm_table->exists(['id'=>$base_data['second_user_id']]))
         $stream->_pushToStream($base_data, $base_data['second_user_id']);
     }
 }
開發者ID:abf6ug,項目名稱:statbro,代碼行數:24,代碼來源:TestShell.php

示例4: main

 /**
  * Start the shell and interactive console.
  *
  * @return int|void
  */
 public function main()
 {
     $sa_table = TableRegistry::get('Friendships');
     $fitbit_accounts = $sa_table->find()->matching('Froms.SocialAccounts', function ($q) {
         return $q->where(['provider' => 'Fitbit']);
     })->contain(['Tos']);
     $game = TableRegistry::get('Games');
     $controller = new AppController();
     $stream = $controller->loadComponent('Stream');
     $tm_table = TableRegistry::get('TempMembers');
     debug(Time::now()->i18nFormat('yyyy-MM-dd 00:00:00'));
     $lr_table = TableRegistry::get('LinkedRecords');
     foreach ($fitbit_accounts as $fitbit_account) {
         //find all pairings of fitbit friends
         if (empty($social_accounts = $fitbit_account['to']['social_accounts'])) {
             continue;
         }
         $fitbit_social_account = false;
         foreach ($social_accounts as $social_account) {
             if ($social_account->provider == 'Fitbit') {
                 $fitbit_social_account = $social_account->id;
             }
         }
         if (!$fitbit_social_account) {
             continue;
         }
         //
         //find todays linked record
         $to = $lr_table->find()->where(['social_account_id' => $fitbit_social_account, 'associated_date' => Time::now()->i18nFormat('yyyy-MM-dd 00:00:00')]);
         if (!$to->first()) {
             continue;
         }
         //
         //            debug($to->first());
         //            return;
         $to_mem = ['member_id' => $fitbit_account->to->id, 'points' => null, 'role' => 'member', 'linked_record_id' => $to->first()->id];
         if (empty($social_accounts = $fitbit_account['from']['social_accounts'])) {
             continue;
         }
         $fitbit_social_account = false;
         foreach ($social_accounts as $social_account) {
             if ($social_account->provider == 'Fitbit') {
                 $fitbit_social_account = $social_account->id;
             }
         }
         if (!$fitbit_social_account) {
             continue;
         }
         $from = $lr_table->find()->where(['social_account_id' => $fitbit_social_account, 'associated_date' => Time::now()->i18nFormat('yyyy-MM-dd 00:00:00')]);
         if (!$from->first()) {
             continue;
         }
         $from_mem = ['member_id' => $fitbit_account->from->id, 'points' => null, 'role' => 'member', 'linked_record_id' => $from->first()->id];
         $game_array = ['status' => 'complete', 'score_type' => 'score', 'game_type_id' => '81e376fa-9f08-4814-82e7-00a2cbf1935b', 'game_memberships' => [$to_mem, $from_mem]];
         $new_game = $game->newEntity($game_array);
         if ($game->save($new_game)) {
             $base_data = $stream->_createStreamData($new_game->id, 'Game');
             Debugger::log($base_data);
             if ($base_data) {
                 if (!$tm_table->exists(['id' => $base_data['first_user_id']])) {
                     $stream->_pushToStream($base_data, $base_data['first_user_id']);
                 }
                 if (!$tm_table->exists(['id' => $base_data['second_user_id']])) {
                     $stream->_pushToStream($base_data, $base_data['second_user_id']);
                 }
             }
         }
     }
 }
開發者ID:abf6ug,項目名稱:statbro,代碼行數:74,代碼來源:CreateFitbitGamesShell.php


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