当前位置: 首页>>代码示例>>PHP>>正文


PHP Review::from_array方法代码示例

本文整理汇总了PHP中Review::from_array方法的典型用法代码示例。如果您正苦于以下问题:PHP Review::from_array方法的具体用法?PHP Review::from_array怎么用?PHP Review::from_array使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Review的用法示例。


在下文中一共展示了Review::from_array方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: grabber

 public function grabber(array $directory_user)
 {
     log_message('TASK_DEBUG', __FUNCTION__ . ' > ' . 'Reviews grabber');
     try {
         $directoryUser = new Directory_User($directory_user['id']);
         if (!$directoryUser->exists()) {
             throw new Exception('Directory_User id:' . $directory_user['id'] . ' doesn\'t exist');
         }
         $directory = $directoryUser->directory->get();
         if (!$directory->exists()) {
             throw new Exception('Directory id:' . $directory_user['directory_id'] . ' doesn\'t exist');
         }
         if (!$directory->status) {
             throw new Exception('Directory id:' . $directory_user['directory_id'] . ' is disabled');
         }
         $link = !empty($directory_user['additional']) ? $directory_user['additional'] : $directory_user['link'];
         log_message('TASK_DEBUG', __FUNCTION__ . ' > ' . 'Try to grabb - ' . $directory->name);
         $aac = $this->getAAC();
         $user = new User($directory_user['user_id']);
         if (!$user->exists()) {
             return;
         }
         $aac->setUser($user);
         $directory_parcer = Directory_Parser::factory($directory->type)->set_url($link);
         $reviews = $directory_parcer->get_reviews();
         /**
          * Store additional data to
          */
         if ($directory_parcer instanceof Directory_Interface_UserStorage) {
             $directoryUser->setAdditional($directory_parcer->getDataToStore())->save();
         }
     } catch (Exception $e) {
         log_message('TASK_ERROR', __FUNCTION__ . ' > ' . 'Reviews: ' . $e->getMessage());
         throw $e;
     }
     //$today_midnight = strtotime('-7 day midnight');
     $today_midnight = strtotime('-14 day midnight');
     if (is_array($reviews) && !empty($reviews)) {
         foreach ($reviews as $_review) {
             $review_model = new Review();
             $review_model->from_array($_review);
             $review_model->user_id = $directory_user['user_id'];
             $review_model->directory_id = $directory_user['directory_id'];
             $review_model->profile_id = $directory_user['profile_id'];
             $review_model->posted_date = date('Y-m-d', $_review['posted']);
             $review_model->save();
             log_message('TASK_DEBUG', __FUNCTION__ . ' > ' . 'Review saved');
         }
     }
 }
开发者ID:andrewkrug,项目名称:repucaution,代码行数:50,代码来源:reviews_task.php

示例2: grabb

 protected function grabb($directory_user)
 {
     log_message('TASK_ERROR', __FUNCTION__ . ' > ' . 'Reviews grabber');
     try {
         $directory = new DM_Directory($directory_user['directory_id']);
         if (!$directory->exists()) {
             throw new Exception('Directory id:' . $directory_user['directory_id'] . ' doesn\'t exist');
         }
         if (!$directory->status) {
             throw new Exception('Directory id:' . $directory_user['directory_id'] . ' is disabled');
         }
         $link = !empty($directory_user['additional']) && !($directory->type == 'Foursquare') ? $directory_user['additional'] : $directory_user['link'];
         $directory_parcer = Directory_Parser::factory($directory->type)->set_url($link);
         //For fousquare only
         $directory_parcer->set_directory_user($directory_user);
         $reviews = $directory_parcer->get_reviews();
     } catch (Exception $e) {
         log_message('TASK_ERROR', __FUNCTION__ . ' > ' . 'Reviews: ' . $e->getMessage());
         throw $e;
     }
     //$today_midnight = strtotime('-7 day midnight');
     $today_midnight = strtotime('-34 day midnight');
     if (is_array($reviews) && !empty($reviews)) {
         foreach ($reviews as $_review) {
             $review_model = new Review();
             $review_model->from_array($_review);
             $review_model->user_id = $directory_user['user_id'];
             $review_model->directory_id = $directory_user['directory_id'];
             $review_model->posted_date = date('Y-m-d', $_review['posted']);
             $review_model->save();
             if (!$review_model->id) {
                 var_dump($review_model->error);
             }
             log_message('TASK_ERROR', __FUNCTION__ . ' > ' . 'Review saved');
             // notify user about new review
             if ($_review['posted'] > $today_midnight && !empty($review_model->id) && !empty($directory_user['user_id']) && !empty($directory_user['notify'])) {
                 $obj = Reviews_notification::addOne($directory_user['user_id'], $review_model->id);
                 if (!$obj->id) {
                     echo 'Error notification: ' . date('d-m-Y H:i') . ' - ' . $obj->error->string . PHP_EOL;
                 }
             }
         }
     }
 }
开发者ID:andrewkrug,项目名称:repucaution,代码行数:44,代码来源:tests.php

示例3: grabber

 public function grabber(array $directory_user)
 {
     try {
         $directory = new DM_Directory($directory_user['directory_id']);
         if (!$directory->exists()) {
             throw new Exception('Directory id:' . $directory_user['directory_id'] . ' doesn\'t exist');
         }
         if (!$directory->status) {
             throw new Exception('Directory id:' . $directory_user['directory_id'] . ' is disabled');
         }
         $link = !empty($directory_user['additional']) ? $directory_user['additional'] : $directory_user['link'];
         $directory_parcer = Directory_Parser::factory($directory->type)->set_url($link);
         $reviews = $directory_parcer->get_reviews();
     } catch (Exception $e) {
         throw $e;
     }
     //$today_midnight = strtotime('-7 day midnight');
     $today_midnight = strtotime('-14 day midnight');
     foreach ($reviews as $_review) {
         $review_model = new Review();
         $review_model->from_array($_review);
         $review_model->user_id = $directory_user['user_id'];
         $review_model->directory_id = $directory_user['directory_id'];
         $review_model->posted_date = date('Y-m-d', $_review['posted']);
         $review_model->save();
         // notify user about new review
         if (!empty($directory_user['notify_status']) && $_review['posted'] > $today_midnight && !empty($review_model->id) && !empty($directory_user['user_id']) && !empty($directory_user['notify'])) {
             $obj = Reviews_notification::addOne($directory_user['user_id'], $review_model->id);
             if (!$obj->id) {
                 echo 'Error notification: ' . date('d-m-Y H:i') . ' - ' . $obj->error->string . PHP_EOL;
             }
         }
     }
 }
开发者ID:andrewkrug,项目名称:repucaution,代码行数:34,代码来源:hard.php


注:本文中的Review::from_array方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。