-
Notifications
You must be signed in to change notification settings - Fork 0
/
LocalDataSocialAPIDecorator.php
46 lines (39 loc) · 1.15 KB
/
LocalDataSocialAPIDecorator.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
class LocalDataSocialAPIDecorator extends SocialAPIDecorator{
public function findCity($city) {
return $this->_component->findCity($city);
}
public function findUser($name, $city_id = false) {
$ret = $this->_component->findUser($name, $city_id);
/* KOSTIL */
if(count($ret['items']) === 0){
$ids = $this->getRedis()->smembers($name);
// echoln("IDS FROM REDIS => " . count($ids));
if(count($ids)){
$ret = $this->getUsersByIds($ids);
} else {
$str = str_repeat('#', 50);
echoln($str);
echoln("Странно, пользователя нет в локальной базе и нет в API!!! '$name'");
echoln($str);
$ret = ['count' => 0, 'items' => []];
}
}
/* /KOSTIL */
return $ret;
}
public function getRedis(){
static $redis = null;
if($redis === null){
$redis = new Predis\Client();
}
return $redis;
}
public function getUsersByIds(array $ids) {
return $this->_component->getUsersByIds($ids);
}
public function getAvatars($id) {
return $this->_component->getAvatars($id);
}
//put your code here
}