зеркало из https://github.com/nextcloud/activity.git
Move registration of the Consumer to the Application
This commit is contained in:
Родитель
d336312e56
Коммит
6e5e712882
|
@ -23,11 +23,11 @@
|
|||
$app = new \OCA\Activity\AppInfo\Application();
|
||||
$c = $app->getContainer();
|
||||
$app->registerNavigationEntry();
|
||||
$app->registerActivityConsumer();
|
||||
|
||||
// register the hooks for filesystem operations. All other events from other apps has to be send via the public api
|
||||
\OCA\Activity\FilesHooksStatic::register();
|
||||
\OCP\Util::connectHook('OC_User', 'post_deleteUser', 'OCA\Activity\Hooks', 'deleteUser');
|
||||
\OCA\Activity\Consumer::register($c->getServer()->getActivityManager(), $c);
|
||||
|
||||
// Personal settings for notifications and emails
|
||||
\OCP\App::registerPersonal($c->getAppName(), 'personal');
|
||||
|
|
|
@ -276,4 +276,17 @@ class Application extends App {
|
|||
};
|
||||
$server->getNavigationManager()->add($navigationEntry);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers the consumer to the Activity Manager
|
||||
*/
|
||||
public function registerActivityConsumer() {
|
||||
$c = $this->getContainer();
|
||||
/** @var \OCP\IServerContainer $server */
|
||||
$server = $c->getServer();
|
||||
|
||||
$server->getActivityManager()->registerConsumer(function() use ($c) {
|
||||
return $c->query('Consumer');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,17 +30,6 @@ use OCP\AppFramework\IAppContainer;
|
|||
use OCP\L10N\IFactory;
|
||||
|
||||
class Consumer implements IConsumer {
|
||||
/**
|
||||
* Registers the consumer to the Activity Manager
|
||||
*
|
||||
* @param IManager $am
|
||||
* @param IAppContainer $container
|
||||
*/
|
||||
public static function register(IManager $am, IAppContainer $container) {
|
||||
$am->registerConsumer(function() use ($container) {
|
||||
return $container->query('Consumer');
|
||||
});
|
||||
}
|
||||
|
||||
/** @var Data */
|
||||
protected $data;
|
||||
|
|
|
@ -182,27 +182,4 @@ class ConsumerTest extends TestCase {
|
|||
|
||||
$consumer->receive($event);
|
||||
}
|
||||
|
||||
public function testRegister() {
|
||||
$activityManager = new \OC\Activity\Manager(
|
||||
$this->getMock('OCP\IRequest'),
|
||||
$this->getMock('OCP\IUserSession'),
|
||||
$this->getMock('OCP\IConfig')
|
||||
);
|
||||
$consumer = new Consumer($this->data, $this->userSettings, $this->l10nFactory);
|
||||
$container = $this->getMock('\OCP\AppFramework\IAppContainer');
|
||||
$container->expects($this->any())
|
||||
->method('query')
|
||||
->with($this->stringContains('Consumer'))
|
||||
->will($this->returnValueMap(array(
|
||||
array('Consumer', $consumer),
|
||||
)));
|
||||
|
||||
Consumer::register($activityManager, $container);
|
||||
|
||||
$consumers = $this->invokePrivate($activityManager, 'getConsumers');
|
||||
$this->assertCount(1, $consumers);
|
||||
$this->assertInstanceOf('OCA\Activity\Consumer', $consumers[0]);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче