initial implementation of activity manager
This commit is contained in:
parent
2e1e283592
commit
48b5c1d5f9
|
@ -0,0 +1,48 @@
|
||||||
|
<?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;
|
||||||
|
|
||||||
|
class ActivityManager implements \OCP\Activity\IManager {
|
||||||
|
|
||||||
|
private $consumers = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $app
|
||||||
|
* @param $subject
|
||||||
|
* @param $message
|
||||||
|
* @param $file
|
||||||
|
* @param $link
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
function publishActivity($app, $subject, $message, $file, $link) {
|
||||||
|
foreach($this->consumers as $consumer) {
|
||||||
|
$c = $consumer();
|
||||||
|
if ($c instanceof IConsumer) {
|
||||||
|
$c->receive($app, $subject, $message, $file, $link);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -25,6 +25,14 @@ namespace OCP\Activity;
|
||||||
|
|
||||||
interface IManager {
|
interface IManager {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $app
|
||||||
|
* @param $subject
|
||||||
|
* @param $message
|
||||||
|
* @param $file
|
||||||
|
* @param $link
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
function publishActivity($app, $subject, $message, $file, $link);
|
function publishActivity($app, $subject, $message, $file, $link);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1400,6 +1400,11 @@ class Share {
|
||||||
'id' => $parent,
|
'id' => $parent,
|
||||||
'token' => $token
|
'token' => $token
|
||||||
));
|
));
|
||||||
|
|
||||||
|
// hook up activity manager
|
||||||
|
$subject = 'Something has been shared';
|
||||||
|
\OC::$server->getActivityManager()->publishActivity('files_sharing', $subject, '', '', '');
|
||||||
|
|
||||||
if ($parentFolder === true) {
|
if ($parentFolder === true) {
|
||||||
// Return parent folders to preserve file target paths for potential children
|
// Return parent folders to preserve file target paths for potential children
|
||||||
return $parentFolders;
|
return $parentFolders;
|
||||||
|
|
|
@ -114,6 +114,9 @@ class Server extends SimpleContainer implements IServerContainer {
|
||||||
$this->registerService('UserCache', function($c) {
|
$this->registerService('UserCache', function($c) {
|
||||||
return new UserCache();
|
return new UserCache();
|
||||||
});
|
});
|
||||||
|
$this->registerService('ActivityManager', function($c) {
|
||||||
|
return new ActivityManager();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -252,4 +255,13 @@ class Server extends SimpleContainer implements IServerContainer {
|
||||||
function getDatabaseConnection() {
|
function getDatabaseConnection() {
|
||||||
return \OC_DB::getConnection();
|
return \OC_DB::getConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the activity manager
|
||||||
|
*
|
||||||
|
* @return \OCP\Activity\IManager
|
||||||
|
*/
|
||||||
|
function getActivityManager() {
|
||||||
|
return $this->query('ActivityManager');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue