Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2013-10-09 20:06:21 +0400
committerThomas Müller <thomas.mueller@tmit.eu>2013-10-09 20:06:21 +0400
commit8e97752bf76aa3b7fb15d734259a9dcd0d82cc73 (patch)
tree42427a9b2b0f2671480774603808c0bfcfa84112 /lib/private/activitymanager.php
parent926b3c9b7be2c3f0d71a64a60006d373f689da39 (diff)
adding OC6 public API for activities
Diffstat (limited to 'lib/private/activitymanager.php')
-rwxr-xr-xlib/private/activitymanager.php69
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);
+ }
+
+}