Skip to content

Commit 22bd641

Browse files
committed
Merge pull request #163 from heiglandreas/hotfix/twitterlistAPI
Fixes twitter-list when an exception occurs
2 parents 1ac12cd + 55f65b8 commit 22bd641

File tree

1 file changed

+39
-31
lines changed

1 file changed

+39
-31
lines changed

Diff for: src/module/Phpug/src/Phpug/Api/Rest/TwitterController.php

+39-31
Original file line numberDiff line numberDiff line change
@@ -52,39 +52,47 @@ public function getList()
5252

5353
$result = array();
5454
foreach ($twitters as $twitter) {
55-
$group = $twitter->getGroup();
56-
if (!$group) {
57-
continue;
58-
}
59-
if (! $group instanceof Usergroup) {
60-
continue;
61-
}
62-
if ($group->getState() != Usergroup::ACTIVE) {
63-
continue;
64-
}
65-
if (! isset($result[$twitter->getName()])) {
66-
$result[$twitter->getName()] = array(
67-
'screen_name' => $twitter->getName(),
68-
'name' => $twitterService->getInfoForUser('name', $twitter->getName()),
69-
'url' => $twitter->getUrl(),
70-
'icon_url' => $twitterService->getInfoForUser('profile_image_url_https', $twitter->getName()),
71-
'groups' => array(),
72-
);
73-
}
74-
$groupMapUrl = $this->url()->fromRoute('home', array(), array('force_canonical' => true)) . '?center=' . $group->getShortName();
75-
$groupApiUrl = $this->url()->fromRoute(
76-
'api/rest', array(
55+
try {
56+
$group = $twitter->getGroup();
57+
if (! $group) {
58+
continue;
59+
}
60+
if (! $group instanceof Usergroup) {
61+
continue;
62+
}
63+
if ($group->getState() != Usergroup::ACTIVE) {
64+
continue;
65+
}
66+
if (! isset($result[$twitter->getName()])) {
67+
$result[$twitter->getName()] = array(
68+
'screen_name' => $twitter->getName(),
69+
'name' => $twitterService->getInfoForUser('name',
70+
$twitter->getName()),
71+
'url' => $twitter->getUrl(),
72+
'icon_url' => $twitterService->getInfoForUser('profile_image_url_https',
73+
$twitter->getName()),
74+
'groups' => array(),
75+
);
76+
}
77+
$groupMapUrl = $this->url()->fromRoute('home',
78+
array(),
79+
array('force_canonical' => true)) . '?center=' . $group->getShortName();
80+
$groupApiUrl = $this->url()->fromRoute(
81+
'api/rest', array(
7782
'controller' => 'Usergroup',
78-
'id' => $group->getId(),
83+
'id' => $group->getId(),
7984
),
80-
array('force_canonical' => true)
81-
);
82-
$result[$twitter->getName()]['groups'][] = array(
83-
'usergroup' => $group->getName(),
84-
'usergroup_url' => $group->getUrl(),
85-
'phpug_group_map_url' => $groupMapUrl,
86-
'phpug_group_api_url' => $groupApiUrl,
87-
);
85+
array('force_canonical' => true)
86+
);
87+
$result[$twitter->getName()]['groups'][] = array(
88+
'usergroup' => $group->getName(),
89+
'usergroup_url' => $group->getUrl(),
90+
'phpug_group_map_url' => $groupMapUrl,
91+
'phpug_group_api_url' => $groupApiUrl,
92+
);
93+
} catch (\Exception $e) {
94+
95+
}
8896
}
8997

9098
usort($result, function($a, $b){

0 commit comments

Comments
 (0)