Move registration of the Consumer to the Application

This commit is contained in:
Joas Schilling 2016-05-10 15:09:58 +02:00
Родитель d336312e56
Коммит 6e5e712882
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 70A0B324C41C0946
4 изменённых файлов: 14 добавлений и 35 удалений

Просмотреть файл

@ -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]);
}
}