diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2013-10-09 18:06:21 +0200 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2013-10-09 18:06:21 +0200 |
commit | 8e97752bf76aa3b7fb15d734259a9dcd0d82cc73 (patch) | |
tree | 42427a9b2b0f2671480774603808c0bfcfa84112 /lib/private/activitymanager.php | |
parent | 926b3c9b7be2c3f0d71a64a60006d373f689da39 (diff) | |
download | nextcloud-server-8e97752bf76aa3b7fb15d734259a9dcd0d82cc73.tar.gz nextcloud-server-8e97752bf76aa3b7fb15d734259a9dcd0d82cc73.zip |
adding OC6 public API for activities
Diffstat (limited to 'lib/private/activitymanager.php')
-rwxr-xr-x | lib/private/activitymanager.php | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/lib/private/activitymanager.php b/lib/private/activitymanager.php new file mode 100755 index 00000000000..7e7e2257874 --- /dev/null +++ b/lib/private/activitymanager.php @@ -0,0 +1,69 @@ +<?php +/** + * Copyright (c) 2013 Thomas Müller thomas.mueller@tmit.eu + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + * + */ +namespace OC; + + +use OCP\Activity\IConsumer; +use OCP\Activity\IManager; + +class ActivityManager implements IManager { + + private $consumers = array(); + + /** + * @param $app + * @param $subject + * @param $subjectParams + * @param $message + * @param $messageParams + * @param $file + * @param $link + * @param $affectedUser + * @param $type + * @param $priority + * @return mixed + */ + function publishActivity($app, $subject, $subjectParams, $message, $messageParams, $file, $link, $affectedUser, $type, $priority) { + foreach($this->consumers as $consumer) { + $c = $consumer(); + if ($c instanceof IConsumer) { + try { + $c->receive( + $app, + $subject, + $subjectParams, + $message, + $messageParams, + $file, + $link, + $affectedUser, + $type, + $priority); + } catch (\Exception $ex) { + // TODO: log the excepetion + } + } + + } + } + + /** + * In order to improve lazy loading a closure can be registered which will be called in case + * activity consumers are actually requested + * + * $callable has to return an instance of OCA\Activity\IConsumer + * + * @param string $key + * @param \Closure $callable + */ + function registerConsumer(\Closure $callable) { + array_push($this->consumers, $callable); + } + +} |