aboutsummaryrefslogtreecommitdiffstats
path: root/apps/settings
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2020-07-16 17:08:03 +0200
committerMorris Jobke <hey@morrisjobke.de>2020-07-21 20:43:18 +0200
commit91e7f12088cb87ffef5660429ece404364167978 (patch)
treebaf44ebc7b240bd49eb0f6bf615cbb1ed99d13db /apps/settings
parente029055e766298c5852eedabf06ff42b06a50198 (diff)
downloadnextcloud-server-91e7f12088cb87ffef5660429ece404364167978.tar.gz
nextcloud-server-91e7f12088cb87ffef5660429ece404364167978.zip
Adjust apps' code to use the ContainerInterface
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'apps/settings')
-rw-r--r--apps/settings/lib/AppInfo/Application.php55
1 files changed, 29 insertions, 26 deletions
diff --git a/apps/settings/lib/AppInfo/Application.php b/apps/settings/lib/AppInfo/Application.php
index 73db869bc6a..3ea4d6bc080 100644
--- a/apps/settings/lib/AppInfo/Application.php
+++ b/apps/settings/lib/AppInfo/Application.php
@@ -40,6 +40,7 @@ use BadMethodCallException;
use OC\AppFramework\Utility\TimeFactory;
use OC\Authentication\Token\IProvider;
use OC\Authentication\Token\IToken;
+use OC\Group\Manager;
use OC\Server;
use OCA\Settings\Activity\Provider;
use OCA\Settings\Hooks;
@@ -52,6 +53,7 @@ use OCP\AppFramework\Bootstrap\IBootstrap;
use OCP\AppFramework\Bootstrap\IRegistrationContext;
use OCP\Defaults;
use OCP\IGroup;
+use OCP\IGroupManager;
use OCP\ILogger;
use OCP\IServerContainer;
use OCP\IUser;
@@ -134,38 +136,39 @@ class Application extends App implements IBootstrap {
}
public function boot(IBootContext $context): void {
- /** @var EventDispatcherInterface $eventDispatcher */
- $eventDispatcher = $context->getServerContainer()->getEventDispatcher();
- $container = $context->getAppContainer();
- $eventDispatcher->addListener('app_password_created', function (GenericEvent $event) use ($container) {
- if (($token = $event->getSubject()) instanceof IToken) {
- /** @var IActivityManager $activityManager */
- $activityManager = $container->query(IActivityManager::class);
- /** @var ILogger $logger */
- $logger = $container->query(ILogger::class);
-
- $activity = $activityManager->generateEvent();
- $activity->setApp('settings')
- ->setType('security')
- ->setAffectedUser($token->getUID())
- ->setAuthor($token->getUID())
- ->setSubject(Provider::APP_TOKEN_CREATED, ['name' => $token->getName()])
- ->setObject('app_token', $token->getId());
-
- try {
- $activityManager->publish($activity);
- } catch (BadMethodCallException $e) {
- $logger->logException($e, ['message' => 'could not publish activity', 'level' => ILogger::WARN]);
+ $context->injectFn(function (EventDispatcherInterface $dispatcher, ContainerInterface $container) {
+ $dispatcher->addListener('app_password_created', function (GenericEvent $event) use ($container) {
+ if (($token = $event->getSubject()) instanceof IToken) {
+ /** @var IActivityManager $activityManager */
+ $activityManager = $container->get(IActivityManager::class);
+ /** @var ILogger $logger */
+ $logger = $container->get(ILogger::class);
+
+ $activity = $activityManager->generateEvent();
+ $activity->setApp('settings')
+ ->setType('security')
+ ->setAffectedUser($token->getUID())
+ ->setAuthor($token->getUID())
+ ->setSubject(Provider::APP_TOKEN_CREATED, ['name' => $token->getName()])
+ ->setObject('app_token', $token->getId());
+
+ try {
+ $activityManager->publish($activity);
+ } catch (BadMethodCallException $e) {
+ $logger->logException($e, ['message' => 'could not publish activity', 'level' => ILogger::WARN]);
+ }
}
- }
+ });
});
Util::connectHook('OC_User', 'post_setPassword', $this, 'onChangePassword');
Util::connectHook('OC_User', 'changeUser', $this, 'onChangeInfo');
- $groupManager = $context->getServerContainer()->getGroupManager();
- $groupManager->listen('\OC\Group', 'postRemoveUser', [$this, 'removeUserFromGroup']);
- $groupManager->listen('\OC\Group', 'postAddUser', [$this, 'addUserToGroup']);
+ $context->injectFn(function (IGroupManager $groupManager) {
+ /** @var IGroupManager|Manager $groupManager */
+ $groupManager->listen('\OC\Group', 'postRemoveUser', [$this, 'removeUserFromGroup']);
+ $groupManager->listen('\OC\Group', 'postAddUser', [$this, 'addUserToGroup']);
+ });
Util::connectHook('\OCP\Config', 'js', $this, 'extendJsConfig');
}