本文整理汇总了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');
}
}
}
示例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;
}
}
}
}
}
示例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;
}
}
}
}