summaryrefslogtreecommitdiffstats
path: root/lib/public/activity
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@owncloud.com>2015-08-19 17:37:55 +0200
committerJoas Schilling <nickvergessen@owncloud.com>2015-08-19 17:44:57 +0200
commit4314c8fc6f5560323e3c811cf2ce40f22d718211 (patch)
tree90130f145ffa4a1caa4c68953b32a0736ba821bf /lib/public/activity
parente985dcc5a079c5b51956e7f42c5c36e310b03679 (diff)
downloadnextcloud-server-4314c8fc6f5560323e3c811cf2ce40f22d718211.tar.gz
nextcloud-server-4314c8fc6f5560323e3c811cf2ce40f22d718211.zip
Use an IEvent object instead of a huge parameter list
Diffstat (limited to 'lib/public/activity')
-rw-r--r--lib/public/activity/iconsumer.php16
-rw-r--r--lib/public/activity/ievent.php200
-rw-r--r--lib/public/activity/imanager.php20
3 files changed, 218 insertions, 18 deletions
diff --git a/lib/public/activity/iconsumer.php b/lib/public/activity/iconsumer.php
index c676f9e308b..e74884d76c5 100644
--- a/lib/public/activity/iconsumer.php
+++ b/lib/public/activity/iconsumer.php
@@ -37,21 +37,11 @@ namespace OCP\Activity;
*/
interface IConsumer {
/**
- * @param string $app The app where this event is associated with
- * @param string $subject A short description of the event
- * @param array $subjectParams Array with parameters that are filled in the subject
- * @param string $message A longer description of the event
- * @param array $messageParams Array with parameters that are filled in the message
- * @param string $file The file including path where this event is associated with
- * @param string $link A link where this event is associated with
- * @param string $affectedUser Recipient of the notification
- * @param string $type Type of the notification
- * @param string $objectType Object type can be used to filter the activities later (e.g. files)
- * @param int $objectId Object id can be used to filter the activities later (e.g. the ID of the cache entry)
+ * @param IEvent $event
* @return null
* @since 6.0.0
- * @since 8.2.0 Added $objectType and $objectId
+ * @since 8.2.0 Replaced the parameters with an IEvent object
*/
- public function receive($app, $subject, $subjectParams, $message, $messageParams, $file, $link, $affectedUser, $type, $objectType, $objectId);
+ public function receive(IEvent $event);
}
diff --git a/lib/public/activity/ievent.php b/lib/public/activity/ievent.php
new file mode 100644
index 00000000000..184c7ae503f
--- /dev/null
+++ b/lib/public/activity/ievent.php
@@ -0,0 +1,200 @@
+<?php
+/**
+ * @author Joas Schilling <nickvergessen@owncloud.com>
+ *
+ * @copyright Copyright (c) 2015, ownCloud, Inc.
+ * @license AGPL-3.0
+ *
+ * This code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License, version 3,
+ * along with this program. If not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+/**
+ * Public interface of ownCloud for apps to use.
+ * Activity/IEvent interface
+ */
+
+// use OCP namespace for all classes that are considered public.
+// This means that they should be used by apps instead of the internal ownCloud classes
+namespace OCP\Activity;
+
+/**
+ * Interface IEvent
+ *
+ * @package OCP\Activity
+ * @since 8.2.0
+ */
+interface IEvent {
+ /**
+ * Set the app of the activity
+ *
+ * @param string $app
+ * @return IEvent
+ * @since 8.2.0
+ */
+ public function setApp($app);
+
+ /**
+ * Set the type of the activity
+ *
+ * @param string $type
+ * @return IEvent
+ * @since 8.2.0
+ */
+ public function setType($type);
+
+ /**
+ * Set the affected user of the activity
+ *
+ * @param string $user
+ * @return IEvent
+ * @since 8.2.0
+ */
+ public function setAffectedUser($user);
+
+ /**
+ * Set the author of the activity
+ *
+ * @param string $author
+ * @return IEvent
+ * @since 8.2.0
+ */
+ public function setAuthor($author);
+
+ /**
+ * Set the author of the activity
+ *
+ * @param int $timestamp
+ * @return IEvent
+ * @since 8.2.0
+ */
+ public function setTimestamp($timestamp);
+
+ /**
+ * Set the subject of the activity
+ *
+ * @param string $subject
+ * @param array $parameters
+ * @return IEvent
+ * @since 8.2.0
+ */
+ public function setSubject($subject, array $parameters = []);
+
+ /**
+ * Set the message of the activity
+ *
+ * @param string $message
+ * @param array $parameters
+ * @return IEvent
+ * @since 8.2.0
+ */
+ public function setMessage($message, array $parameters = []);
+
+ /**
+ * Set the object of the activity
+ *
+ * @param string $objectType
+ * @param int $objectId
+ * @param string $objectName
+ * @return IEvent
+ * @since 8.2.0
+ */
+ public function setObject($objectType, $objectId, $objectName = '');
+
+ /**
+ * Set the link of the activity
+ *
+ * @param string $link
+ * @return IEvent
+ * @since 8.2.0
+ */
+ public function setLink($link);
+
+ /**
+ * @return string
+ * @since 8.2.0
+ */
+ public function getApp();
+
+ /**
+ * @return string
+ * @since 8.2.0
+ */
+ public function getType();
+
+ /**
+ * @return string
+ * @since 8.2.0
+ */
+ public function getAffectedUser();
+
+ /**
+ * @return string
+ * @since 8.2.0
+ */
+ public function getAuthor();
+
+ /**
+ * @return int
+ * @since 8.2.0
+ */
+ public function getTimestamp();
+
+ /**
+ * @return string
+ * @since 8.2.0
+ */
+ public function getSubject();
+
+ /**
+ * @return array
+ * @since 8.2.0
+ */
+ public function getSubjectParameters();
+
+ /**
+ * @return string
+ * @since 8.2.0
+ */
+ public function getMessage();
+
+ /**
+ * @return array
+ * @since 8.2.0
+ */
+ public function getMessageParameters();
+
+ /**
+ * @return string
+ * @since 8.2.0
+ */
+ public function getObjectType();
+
+ /**
+ * @return string
+ * @since 8.2.0
+ */
+ public function getObjectId();
+
+ /**
+ * @return string
+ * @since 8.2.0
+ */
+ public function getObjectName();
+
+ /**
+ * @return string
+ * @since 8.2.0
+ */
+ public function getLink();
+}
diff --git a/lib/public/activity/imanager.php b/lib/public/activity/imanager.php
index ef34168e610..c3818234f79 100644
--- a/lib/public/activity/imanager.php
+++ b/lib/public/activity/imanager.php
@@ -38,6 +38,18 @@ namespace OCP\Activity;
* @since 6.0.0
*/
interface IManager {
+ /**
+ * @return IEvent
+ * @since 8.2.0
+ */
+ public function generateEvent();
+
+ /**
+ * @param IEvent $event
+ * @return null
+ * @since 8.2.0
+ */
+ public function publish(IEvent $event);
/**
* @param string $app The app where this event is associated with
@@ -49,14 +61,12 @@ interface IManager {
* @param string $link A link where this event is associated with
* @param string $affectedUser Recipient of the activity
* @param string $type Type of the notification
- * @param int $priority Priority of the notification (@deprecated)
- * @param string $objectType Object type can be used to filter the activities later (e.g. files)
- * @param int $objectId Object id can be used to filter the activities later (e.g. the ID of the cache entry)
+ * @param int $priority Priority of the notification
* @return null
* @since 6.0.0
- * @since 8.2.0 Added $objectType and $objectId
+ * @deprecated 8.2.0 Grab an IEvent from generateEvent() instead and use the publish() method
*/
- public function publishActivity($app, $subject, $subjectParams, $message, $messageParams, $file, $link, $affectedUser, $type, $priority, $objectType = '', $objectId = 0);
+ public function publishActivity($app, $subject, $subjectParams, $message, $messageParams, $file, $link, $affectedUser, $type, $priority);
/**
* In order to improve lazy loading a closure can be registered which will be called in case