Inject public IGroupManager instead of private GroupManager

The public "IGroupManager" service returned by the dependency injection
system is automatically initialized with an "OC\Group\Database" backend.
However, no backend is automatically set in private "GroupManager"
instances. Therefore, a private "GroupManager" instance does not work as
expected when initialized through the dependency injection system.

Due to that this commit reverts a previous change in which the public
"IGroupManager" was replaced by a private "GroupManager" instance. That
change was needed when strict types were set, as "getSubAdmin()" is not
part of "IGroupManager" API, so the type had to be changed to
"GroupManager". Until a better solution is found strict types are
disabled again to be able to inject "IGroupManager" and also use
"getSubAdmin()".

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
This commit is contained in:
Daniel Calviño Sánchez 2018-03-13 07:29:12 +01:00
parent 3cae276149
commit 044d5a8d01
2 changed files with 12 additions and 8 deletions

View File

@ -1,5 +1,7 @@
<?php <?php
declare(strict_types=1); // FIXME: disabled for now to be able to inject IGroupManager and also use
// getSubAdmin()
//declare(strict_types=1);
/** /**
* *
* *
@ -27,12 +29,12 @@ declare(strict_types=1);
*/ */
namespace OC\Settings\Controller; namespace OC\Settings\Controller;
use OC\Group\Manager as GroupManager;
use OC\HintException; use OC\HintException;
use OC\User\Session; use OC\User\Session;
use OCP\App\IAppManager; use OCP\App\IAppManager;
use OCP\AppFramework\Controller; use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\JSONResponse; use OCP\AppFramework\Http\JSONResponse;
use OCP\IGroupManager;
use OCP\IL10N; use OCP\IL10N;
use OCP\IRequest; use OCP\IRequest;
use OCP\IUser; use OCP\IUser;
@ -50,7 +52,7 @@ class ChangePasswordController extends Controller {
/** @var IL10N */ /** @var IL10N */
private $l; private $l;
/** @var GroupManager */ /** @var IGroupManager */
private $groupManager; private $groupManager;
/** @var Session */ /** @var Session */
@ -64,7 +66,7 @@ class ChangePasswordController extends Controller {
string $userId, string $userId,
IUserManager $userManager, IUserManager $userManager,
IUserSession $userSession, IUserSession $userSession,
GroupManager $groupManager, IGroupManager $groupManager,
IAppManager $appManager, IAppManager $appManager,
IL10N $l) { IL10N $l) {
parent::__construct($appName, $request); parent::__construct($appName, $request);

View File

@ -1,5 +1,7 @@
<?php <?php
declare(strict_types=1); // FIXME: disabled for now to be able to inject IGroupManager and also use
// getSubAdmin()
//declare(strict_types=1);
/** /**
* @copyright Copyright (c) 2016, ownCloud, Inc. * @copyright Copyright (c) 2016, ownCloud, Inc.
* *
@ -40,7 +42,6 @@ namespace OC\Settings\Controller;
use OC\Accounts\AccountManager; use OC\Accounts\AccountManager;
use OC\AppFramework\Http; use OC\AppFramework\Http;
use OC\ForbiddenException; use OC\ForbiddenException;
use OC\Group\Manager as GroupManager;
use OC\HintException; use OC\HintException;
use OC\Settings\Mailer\NewUserMailHelper; use OC\Settings\Mailer\NewUserMailHelper;
use OC\Security\IdentityProof\Manager; use OC\Security\IdentityProof\Manager;
@ -52,6 +53,7 @@ use OCP\Files\Config\IUserMountCache;
use OCP\Encryption\IEncryptionModule; use OCP\Encryption\IEncryptionModule;
use OCP\Encryption\IManager; use OCP\Encryption\IManager;
use OCP\IConfig; use OCP\IConfig;
use OCP\IGroupManager;
use OCP\IL10N; use OCP\IL10N;
use OCP\ILogger; use OCP\ILogger;
use OCP\IRequest; use OCP\IRequest;
@ -77,7 +79,7 @@ class UsersController extends Controller {
private $isAdmin; private $isAdmin;
/** @var IUserManager */ /** @var IUserManager */
private $userManager; private $userManager;
/** @var GroupManager */ /** @var IGroupManager */
private $groupManager; private $groupManager;
/** @var IConfig */ /** @var IConfig */
private $config; private $config;
@ -113,7 +115,7 @@ class UsersController extends Controller {
public function __construct(string $appName, public function __construct(string $appName,
IRequest $request, IRequest $request,
IUserManager $userManager, IUserManager $userManager,
GroupManager $groupManager, IGroupManager $groupManager,
IUserSession $userSession, IUserSession $userSession,
IConfig $config, IConfig $config,
bool $isAdmin, bool $isAdmin,