X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Factivityutils.php;h=8a2be350225140d6198128ad33d97a42a305c39b;hb=fb537fb7f455cde9c4ccd9f6e54e734467d4f4b3;hp=f3383efda5b4db936a75e8611a09147aa9a0cfc9;hpb=7c4e550e310172ad86e387bc8c417513e7d743fc;p=quix0rs-gnu-social.git diff --git a/lib/activityutils.php b/lib/activityutils.php index f3383efda5..8a2be35022 100644 --- a/lib/activityutils.php +++ b/lib/activityutils.php @@ -348,7 +348,7 @@ class ActivityUtils return null; } - static function compareTypes($type, $objects) // this does verbs too! + static function compareTypes($type, $objects) { $type = self::resolveUri($type); foreach ((array)$objects as $object) { @@ -359,6 +359,11 @@ class ActivityUtils return false; } + static function compareVerbs($type, $objects) + { + return self::compareTypes($type, $objects); + } + static function resolveUri($uri, $make_relative=false) { if (empty($uri)) { @@ -375,32 +380,33 @@ class ActivityUtils } static function findLocalObject(array $uris, $type=ActivityObject::NOTE) { - $object = null; - // TODO: Extend this in plugins etc. - if (Event::handle('StartFindLocalActivityObject', array($uris, $type, &$object))) { + $obj_class = null; + // TODO: Extend this in plugins etc. and describe in EVENTS.txt + if (Event::handle('StartFindLocalActivityObject', array($uris, $type, &$obj_class))) { switch (self::resolveUri($type)) { case ActivityObject::PERSON: // GROUP will also be here in due time... - $object = new Profile(); + $obj_class = 'Profile'; break; default: - $object = new Notice(); + $obj_class = 'Notice'; } } - foreach (array_unique($uris) as $uri) { + $object = null; + $uris = array_unique($uris); + foreach ($uris as $uri) { try { // the exception thrown will cancel before reaching $object - $object = call_user_func(array($object, 'fromUri'), $uri); + $object = call_user_func("{$obj_class}::fromUri", $uri); break; - } catch (Exception $e) { - common_debug('Could not find local activity object from uri: '.$uri); + } catch (UnknownUriException $e) { + common_debug('Could not find local activity object from uri: '.$e->object_uri); } } - if (!empty($object)) { - Event::handle('EndFindLocalActivityObject', array($object->getUri(), $type, $object)); - } else { - throw new ServerException('Could not find any activityobject stored locally with given URI'); + if (!$object instanceof Managed_DataObject) { + throw new ServerException('Could not find any activityobject stored locally with given URIs: '.var_export($uris,true)); } + Event::handle('EndFindLocalActivityObject', array($object->getUri(), $object->getObjectType(), $object)); return $object; }