summaryrefslogtreecommitdiffstats
path: root/apps/admin_audit/lib
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2020-07-21 14:36:40 +0200
committerMorris Jobke <hey@morrisjobke.de>2020-07-21 20:44:05 +0200
commit7870ca06637453f4e72dbd67edbfb3603d813196 (patch)
tree9f61927799c9baf39e336fa4299d4ac0fe4e34a1 /apps/admin_audit/lib
parent91e7f12088cb87ffef5660429ece404364167978 (diff)
downloadnextcloud-server-7870ca06637453f4e72dbd67edbfb3603d813196.tar.gz
nextcloud-server-7870ca06637453f4e72dbd67edbfb3603d813196.zip
Use the proper IAppContainer and IServerContainer type hints to know which code runs with which container
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Diffstat (limited to 'apps/admin_audit/lib')
-rw-r--r--apps/admin_audit/lib/AppInfo/Application.php38
1 files changed, 16 insertions, 22 deletions
diff --git a/apps/admin_audit/lib/AppInfo/Application.php b/apps/admin_audit/lib/AppInfo/Application.php
index 81aeada2aaf..b63c361b51f 100644
--- a/apps/admin_audit/lib/AppInfo/Application.php
+++ b/apps/admin_audit/lib/AppInfo/Application.php
@@ -37,7 +37,6 @@ use Closure;
use OC\Files\Filesystem;
use OC\Files\Node\File;
use OC\Group\Manager;
-use OC\User\Session;
use OCA\AdminAudit\Actions\AppManagement;
use OCA\AdminAudit\Actions\Auth;
use OCA\AdminAudit\Actions\Console;
@@ -59,11 +58,11 @@ use OCP\IConfig;
use OCP\IGroupManager;
use OCP\ILogger;
use OCP\IPreview;
+use OCP\IServerContainer;
use OCP\IUserSession;
use OCP\Log\ILogFactory;
use OCP\Share;
use OCP\Util;
-use Psr\Container\ContainerInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\GenericEvent;
@@ -108,44 +107,43 @@ class Application extends App implements IBootstrap {
* Register hooks in order to log them
*/
private function registerHooks(ILogger $logger,
- ContainerInterface $container) {
- $this->userManagementHooks($logger, $container);
- $this->groupHooks($logger, $container);
+ IServerContainer $serverContainer) {
+ $this->userManagementHooks($logger, $serverContainer->get(IUserSession::class));
+ $this->groupHooks($logger, $serverContainer->get(IGroupManager::class));
$this->authHooks($logger);
- $this->consoleHooks($logger, $container);
- $this->appHooks($logger, $container);
+ /** @var EventDispatcherInterface $eventDispatcher */
+ $eventDispatcher = $serverContainer->get(EventDispatcherInterface::class);
+ $this->consoleHooks($logger, $eventDispatcher);
+ $this->appHooks($logger, $eventDispatcher);
$this->sharingHooks($logger);
- $this->fileHooks($logger, $container);
+ $this->fileHooks($logger, $eventDispatcher);
$this->trashbinHooks($logger);
$this->versionsHooks($logger);
- $this->securityHooks($logger, $container);
+ $this->securityHooks($logger, $eventDispatcher);
}
private function userManagementHooks(ILogger $logger,
- ContainerInterface $container) {
+ IUserSession $userSession) {
$userActions = new UserManagement($logger);
Util::connectHook('OC_User', 'post_createUser', $userActions, 'create');
Util::connectHook('OC_User', 'post_deleteUser', $userActions, 'delete');
Util::connectHook('OC_User', 'changeUser', $userActions, 'change');
- /** @var IUserSession|Session $userSession */
- $userSession = $container->get(IUserSession::class);
$userSession->listen('\OC\User', 'postSetPassword', [$userActions, 'setPassword']);
$userSession->listen('\OC\User', 'assignedUserId', [$userActions, 'assign']);
$userSession->listen('\OC\User', 'postUnassignedUserId', [$userActions, 'unassign']);
}
private function groupHooks(ILogger $logger,
- ContainerInterface $container) {
+ IGroupManager $groupManager) {
$groupActions = new GroupManagement($logger);
/** @var IGroupManager|Manager $groupManager */
- $groupManager = $container->getGroupManager(IGroupManager::class);
$groupManager->listen('\OC\Group', 'postRemoveUser', [$groupActions, 'removeUser']);
$groupManager->listen('\OC\Group', 'postAddUser', [$groupActions, 'addUser']);
$groupManager->listen('\OC\Group', 'postDelete', [$groupActions, 'deleteGroup']);
@@ -173,8 +171,7 @@ class Application extends App implements IBootstrap {
}
private function appHooks(ILogger $logger,
- ContainerInterface $container) {
- $eventDispatcher = $container->get(EventDispatcherInterface::class);
+ EventDispatcherInterface $eventDispatcher) {
$eventDispatcher->addListener(ManagerEvent::EVENT_APP_ENABLE, function (ManagerEvent $event) use ($logger) {
$appActions = new AppManagement($logger);
$appActions->enableApp($event->getAppID());
@@ -190,8 +187,7 @@ class Application extends App implements IBootstrap {
}
private function consoleHooks(ILogger $logger,
- ContainerInterface $container) {
- $eventDispatcher = $container->get(EventDispatcherInterface::class);
+ EventDispatcherInterface $eventDispatcher) {
$eventDispatcher->addListener(ConsoleEvent::EVENT_RUN, function (ConsoleEvent $event) use ($logger) {
$appActions = new Console($logger);
$appActions->runCommand($event->getArguments());
@@ -199,9 +195,8 @@ class Application extends App implements IBootstrap {
}
private function fileHooks(ILogger $logger,
- ContainerInterface $container) {
+ EventDispatcherInterface $eventDispatcher) {
$fileActions = new Files($logger);
- $eventDispatcher = $container->get(EventDispatcherInterface::class);
$eventDispatcher->addListener(
IPreview::EVENT,
function (GenericEvent $event) use ($fileActions) {
@@ -274,8 +269,7 @@ class Application extends App implements IBootstrap {
}
private function securityHooks(ILogger $logger,
- ContainerInterface $container) {
- $eventDispatcher = $container->get(EventDispatcherInterface::class);
+ EventDispatcherInterface $eventDispatcher) {
$eventDispatcher->addListener(IProvider::EVENT_SUCCESS, function (GenericEvent $event) use ($logger) {
$security = new Security($logger);
$security->twofactorSuccess($event->getSubject(), $event->getArguments());