当前位置: 首页>>代码示例>>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;未经允许,请勿转载。