Changes:
- added type-hint for $type parameter - documented method - unsupported verbs logged
This commit is contained in:
parent
a145712f04
commit
9794ce0c87
1 changed files with 15 additions and 3 deletions
|
@ -42,11 +42,16 @@ class Activities extends BaseFactory
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Creates activities array from URI id, user id
|
||||||
|
*
|
||||||
* @param int $uriId Uri-ID of the item
|
* @param int $uriId Uri-ID of the item
|
||||||
* @return Array
|
* @param int $uid User id
|
||||||
|
* @param string $type Type of returned activities, can be 'json' or 'xml', default: json
|
||||||
|
*
|
||||||
|
* @return array Array of found activities
|
||||||
* @throws HTTPException\InternalServerErrorException
|
* @throws HTTPException\InternalServerErrorException
|
||||||
*/
|
*/
|
||||||
public function createFromUriId(int $uriId, int $uid, $type = 'json'): array
|
public function createFromUriId(int $uriId, int $uid, string $type = 'json'): array
|
||||||
{
|
{
|
||||||
$activities = [
|
$activities = [
|
||||||
'like' => [],
|
'like' => [],
|
||||||
|
@ -68,22 +73,29 @@ class Activities extends BaseFactory
|
||||||
case Activity::LIKE:
|
case Activity::LIKE:
|
||||||
$activities['like'][] = $user;
|
$activities['like'][] = $user;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Activity::DISLIKE:
|
case Activity::DISLIKE:
|
||||||
$activities['dislike'][] = $user;
|
$activities['dislike'][] = $user;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Activity::ATTEND:
|
case Activity::ATTEND:
|
||||||
$activities['attendyes'][] = $user;
|
$activities['attendyes'][] = $user;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Activity::ATTENDNO:
|
case Activity::ATTENDNO:
|
||||||
$activities['attendno'][] = $user;
|
$activities['attendno'][] = $user;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Activity::ATTENDMAYBE:
|
case Activity::ATTENDMAYBE:
|
||||||
$activities['attendmaybe'][] = $user;
|
$activities['attendmaybe'][] = $user;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Activity::ANNOUNCE:
|
case Activity::ANNOUNCE:
|
||||||
$activities['announce'][] = $user;
|
$activities['announce'][] = $user;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
$this->logger->warning('Unsupported verb in parent item:', ['parent_item' => $parent_item]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -94,7 +106,7 @@ class Activities extends BaseFactory
|
||||||
$xml_activities = [];
|
$xml_activities = [];
|
||||||
foreach ($activities as $k => $v) {
|
foreach ($activities as $k => $v) {
|
||||||
// change xml element from "like" to "friendica:like"
|
// change xml element from "like" to "friendica:like"
|
||||||
$xml_activities["friendica:".$k] = $v;
|
$xml_activities['friendica:' . $k] = $v;
|
||||||
// add user data into xml output
|
// add user data into xml output
|
||||||
$k_user = 0;
|
$k_user = 0;
|
||||||
foreach ($v as $user) {
|
foreach ($v as $user) {
|
||||||
|
|
Loading…
Reference in a new issue