Use abstract subclass so members can be defined
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
762002ec2e
commit
348171f311
5 changed files with 63 additions and 54 deletions
|
@ -7,10 +7,10 @@ $baseDir = $vendorDir;
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'OCA\\Provisioning_API\\AppInfo\\Application' => $baseDir . '/../lib/AppInfo/Application.php',
|
'OCA\\Provisioning_API\\AppInfo\\Application' => $baseDir . '/../lib/AppInfo/Application.php',
|
||||||
|
'OCA\\Provisioning_API\\Controller\\AUserData' => $baseDir . '/../lib/Controller/AUserData.php',
|
||||||
'OCA\\Provisioning_API\\Controller\\AppConfigController' => $baseDir . '/../lib/Controller/AppConfigController.php',
|
'OCA\\Provisioning_API\\Controller\\AppConfigController' => $baseDir . '/../lib/Controller/AppConfigController.php',
|
||||||
'OCA\\Provisioning_API\\Controller\\AppsController' => $baseDir . '/../lib/Controller/AppsController.php',
|
'OCA\\Provisioning_API\\Controller\\AppsController' => $baseDir . '/../lib/Controller/AppsController.php',
|
||||||
'OCA\\Provisioning_API\\Controller\\GroupsController' => $baseDir . '/../lib/Controller/GroupsController.php',
|
'OCA\\Provisioning_API\\Controller\\GroupsController' => $baseDir . '/../lib/Controller/GroupsController.php',
|
||||||
'OCA\\Provisioning_API\\Controller\\UserDataTrait' => $baseDir . '/../lib/Controller/UserDataTrait.php',
|
|
||||||
'OCA\\Provisioning_API\\Controller\\UsersController' => $baseDir . '/../lib/Controller/UsersController.php',
|
'OCA\\Provisioning_API\\Controller\\UsersController' => $baseDir . '/../lib/Controller/UsersController.php',
|
||||||
'OCA\\Provisioning_API\\FederatedFileSharingFactory' => $baseDir . '/../lib/FederatedFileSharingFactory.php',
|
'OCA\\Provisioning_API\\FederatedFileSharingFactory' => $baseDir . '/../lib/FederatedFileSharingFactory.php',
|
||||||
'OCA\\Provisioning_API\\Middleware\\Exceptions\\NotSubAdminException' => $baseDir . '/../lib/Middleware/Exceptions/NotSubAdminException.php',
|
'OCA\\Provisioning_API\\Middleware\\Exceptions\\NotSubAdminException' => $baseDir . '/../lib/Middleware/Exceptions/NotSubAdminException.php',
|
||||||
|
|
|
@ -22,10 +22,10 @@ class ComposerStaticInitProvisioning_API
|
||||||
|
|
||||||
public static $classMap = array (
|
public static $classMap = array (
|
||||||
'OCA\\Provisioning_API\\AppInfo\\Application' => __DIR__ . '/..' . '/../lib/AppInfo/Application.php',
|
'OCA\\Provisioning_API\\AppInfo\\Application' => __DIR__ . '/..' . '/../lib/AppInfo/Application.php',
|
||||||
|
'OCA\\Provisioning_API\\Controller\\AUserData' => __DIR__ . '/..' . '/../lib/Controller/AUserData.php',
|
||||||
'OCA\\Provisioning_API\\Controller\\AppConfigController' => __DIR__ . '/..' . '/../lib/Controller/AppConfigController.php',
|
'OCA\\Provisioning_API\\Controller\\AppConfigController' => __DIR__ . '/..' . '/../lib/Controller/AppConfigController.php',
|
||||||
'OCA\\Provisioning_API\\Controller\\AppsController' => __DIR__ . '/..' . '/../lib/Controller/AppsController.php',
|
'OCA\\Provisioning_API\\Controller\\AppsController' => __DIR__ . '/..' . '/../lib/Controller/AppsController.php',
|
||||||
'OCA\\Provisioning_API\\Controller\\GroupsController' => __DIR__ . '/..' . '/../lib/Controller/GroupsController.php',
|
'OCA\\Provisioning_API\\Controller\\GroupsController' => __DIR__ . '/..' . '/../lib/Controller/GroupsController.php',
|
||||||
'OCA\\Provisioning_API\\Controller\\UserDataTrait' => __DIR__ . '/..' . '/../lib/Controller/UserDataTrait.php',
|
|
||||||
'OCA\\Provisioning_API\\Controller\\UsersController' => __DIR__ . '/..' . '/../lib/Controller/UsersController.php',
|
'OCA\\Provisioning_API\\Controller\\UsersController' => __DIR__ . '/..' . '/../lib/Controller/UsersController.php',
|
||||||
'OCA\\Provisioning_API\\FederatedFileSharingFactory' => __DIR__ . '/..' . '/../lib/FederatedFileSharingFactory.php',
|
'OCA\\Provisioning_API\\FederatedFileSharingFactory' => __DIR__ . '/..' . '/../lib/FederatedFileSharingFactory.php',
|
||||||
'OCA\\Provisioning_API\\Middleware\\Exceptions\\NotSubAdminException' => __DIR__ . '/..' . '/../lib/Middleware/Exceptions/NotSubAdminException.php',
|
'OCA\\Provisioning_API\\Middleware\\Exceptions\\NotSubAdminException' => __DIR__ . '/..' . '/../lib/Middleware/Exceptions/NotSubAdminException.php',
|
||||||
|
|
|
@ -22,14 +22,54 @@ declare(strict_types=1);
|
||||||
namespace OCA\Provisioning_API\Controller;
|
namespace OCA\Provisioning_API\Controller;
|
||||||
|
|
||||||
use OC\Accounts\AccountManager;
|
use OC\Accounts\AccountManager;
|
||||||
use OCP\AppFramework\Http\DataResponse;
|
|
||||||
use OCP\AppFramework\OCS\OCSException;
|
use OCP\AppFramework\OCS\OCSException;
|
||||||
use OCP\AppFramework\OCS\OCSNotFoundException;
|
use OCP\AppFramework\OCS\OCSNotFoundException;
|
||||||
use OCP\AppFramework\OCS\OCSForbiddenException;
|
use OCP\AppFramework\OCSController;
|
||||||
use OCP\Files\NotFoundException;
|
use OCP\Files\NotFoundException;
|
||||||
use OC_Helper;
|
use OC_Helper;
|
||||||
|
use OCP\IConfig;
|
||||||
|
use OCP\IGroupManager;
|
||||||
|
use OCP\IRequest;
|
||||||
|
use OCP\IUserManager;
|
||||||
|
use OCP\IUserSession;
|
||||||
|
|
||||||
trait UserDataTrait {
|
abstract class AUserData extends OCSController {
|
||||||
|
|
||||||
|
/** @var IUserManager */
|
||||||
|
protected $userManager;
|
||||||
|
/** @var IConfig */
|
||||||
|
protected $config;
|
||||||
|
/** @var IGroupManager|\OC\Group\Manager */ // FIXME Requires a method that is not on the interface
|
||||||
|
protected $groupManager;
|
||||||
|
/** @var IUserSession */
|
||||||
|
protected $userSession;
|
||||||
|
/** @var AccountManager */
|
||||||
|
protected $accountManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $appName
|
||||||
|
* @param IRequest $request
|
||||||
|
* @param IUserManager $userManager
|
||||||
|
* @param IConfig $config
|
||||||
|
* @param IGroupManager $groupManager
|
||||||
|
* @param IUserSession $userSession
|
||||||
|
* @param AccountManager $accountManager
|
||||||
|
*/
|
||||||
|
public function __construct(string $appName,
|
||||||
|
IRequest $request,
|
||||||
|
IUserManager $userManager,
|
||||||
|
IConfig $config,
|
||||||
|
IGroupManager $groupManager,
|
||||||
|
IUserSession $userSession,
|
||||||
|
AccountManager $accountManager) {
|
||||||
|
parent::__construct($appName, $request);
|
||||||
|
|
||||||
|
$this->userManager = $userManager;
|
||||||
|
$this->config = $config;
|
||||||
|
$this->groupManager = $groupManager;
|
||||||
|
$this->userSession = $userSession;
|
||||||
|
$this->accountManager = $accountManager;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* creates a array with all user data
|
* creates a array with all user data
|
||||||
|
@ -38,7 +78,7 @@ trait UserDataTrait {
|
||||||
* @return array
|
* @return array
|
||||||
* @throws OCSException
|
* @throws OCSException
|
||||||
*/
|
*/
|
||||||
public function getUserData(string $userId): array {
|
protected function getUserData(string $userId): array {
|
||||||
$currentLoggedInUser = $this->userSession->getUser();
|
$currentLoggedInUser = $this->userSession->getUser();
|
||||||
|
|
||||||
$data = [];
|
$data = [];
|
||||||
|
@ -134,4 +174,4 @@ trait UserDataTrait {
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -33,7 +33,6 @@ use OCP\AppFramework\Http\DataResponse;
|
||||||
use OCP\AppFramework\OCS\OCSException;
|
use OCP\AppFramework\OCS\OCSException;
|
||||||
use OCP\AppFramework\OCS\OCSNotFoundException;
|
use OCP\AppFramework\OCS\OCSNotFoundException;
|
||||||
use OCP\AppFramework\OCS\OCSForbiddenException;
|
use OCP\AppFramework\OCS\OCSForbiddenException;
|
||||||
use OCP\AppFramework\OCSController;
|
|
||||||
use OCP\IConfig;
|
use OCP\IConfig;
|
||||||
use OCP\IGroup;
|
use OCP\IGroup;
|
||||||
use OCP\IGroupManager;
|
use OCP\IGroupManager;
|
||||||
|
@ -43,24 +42,7 @@ use OCP\IUserManager;
|
||||||
use OCP\IUserSession;
|
use OCP\IUserSession;
|
||||||
use OCP\IUser;
|
use OCP\IUser;
|
||||||
|
|
||||||
class GroupsController extends OCSController {
|
class GroupsController extends AUserData {
|
||||||
|
|
||||||
use UserDataTrait;
|
|
||||||
|
|
||||||
/** @var IUserManager */
|
|
||||||
private $userManager;
|
|
||||||
|
|
||||||
/** @var IGroupManager */
|
|
||||||
private $groupManager;
|
|
||||||
|
|
||||||
/** @var IUserSession */
|
|
||||||
private $userSession;
|
|
||||||
|
|
||||||
/** @var IConfig */
|
|
||||||
private $config;
|
|
||||||
|
|
||||||
/** @var AccountManager */
|
|
||||||
private $accountManager;
|
|
||||||
|
|
||||||
/** @var ILogger */
|
/** @var ILogger */
|
||||||
private $logger;
|
private $logger;
|
||||||
|
@ -84,13 +66,14 @@ class GroupsController extends OCSController {
|
||||||
IUserSession $userSession,
|
IUserSession $userSession,
|
||||||
AccountManager $accountManager,
|
AccountManager $accountManager,
|
||||||
ILogger $logger) {
|
ILogger $logger) {
|
||||||
parent::__construct($appName, $request);
|
parent::__construct($appName,
|
||||||
|
$request,
|
||||||
|
$userManager,
|
||||||
|
$config,
|
||||||
|
$groupManager,
|
||||||
|
$userSession,
|
||||||
|
$accountManager);
|
||||||
|
|
||||||
$this->groupManager = $groupManager;
|
|
||||||
$this->userManager = $userManager;
|
|
||||||
$this->config = $config;
|
|
||||||
$this->userSession = $userSession;
|
|
||||||
$this->accountManager = $accountManager;
|
|
||||||
$this->logger = $logger;
|
$this->logger = $logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,14 +35,11 @@ namespace OCA\Provisioning_API\Controller;
|
||||||
use OC\Accounts\AccountManager;
|
use OC\Accounts\AccountManager;
|
||||||
use OC\HintException;
|
use OC\HintException;
|
||||||
use OC\Settings\Mailer\NewUserMailHelper;
|
use OC\Settings\Mailer\NewUserMailHelper;
|
||||||
use OC_Helper;
|
|
||||||
use OCA\Provisioning_API\FederatedFileSharingFactory;
|
use OCA\Provisioning_API\FederatedFileSharingFactory;
|
||||||
use OCP\App\IAppManager;
|
use OCP\App\IAppManager;
|
||||||
use OCP\AppFramework\Http\DataResponse;
|
use OCP\AppFramework\Http\DataResponse;
|
||||||
use OCP\AppFramework\OCS\OCSException;
|
use OCP\AppFramework\OCS\OCSException;
|
||||||
use OCP\AppFramework\OCS\OCSForbiddenException;
|
use OCP\AppFramework\OCS\OCSForbiddenException;
|
||||||
use OCP\AppFramework\OCSController;
|
|
||||||
use OCP\Files\NotFoundException;
|
|
||||||
use OCP\IConfig;
|
use OCP\IConfig;
|
||||||
use OCP\IGroup;
|
use OCP\IGroup;
|
||||||
use OCP\IGroupManager;
|
use OCP\IGroupManager;
|
||||||
|
@ -53,22 +50,10 @@ use OCP\IUserSession;
|
||||||
use OCP\L10N\IFactory;
|
use OCP\L10N\IFactory;
|
||||||
use OCP\Security\ISecureRandom;
|
use OCP\Security\ISecureRandom;
|
||||||
|
|
||||||
class UsersController extends OCSController {
|
class UsersController extends AUserData {
|
||||||
|
|
||||||
use UserDataTrait;
|
|
||||||
|
|
||||||
/** @var IUserManager */
|
|
||||||
private $userManager;
|
|
||||||
/** @var IConfig */
|
|
||||||
private $config;
|
|
||||||
/** @var IAppManager */
|
/** @var IAppManager */
|
||||||
private $appManager;
|
private $appManager;
|
||||||
/** @var IGroupManager|\OC\Group\Manager */ // FIXME Requires a method that is not on the interface
|
|
||||||
private $groupManager;
|
|
||||||
/** @var IUserSession */
|
|
||||||
private $userSession;
|
|
||||||
/** @var AccountManager */
|
|
||||||
private $accountManager;
|
|
||||||
/** @var ILogger */
|
/** @var ILogger */
|
||||||
private $logger;
|
private $logger;
|
||||||
/** @var IFactory */
|
/** @var IFactory */
|
||||||
|
@ -108,14 +93,15 @@ class UsersController extends OCSController {
|
||||||
NewUserMailHelper $newUserMailHelper,
|
NewUserMailHelper $newUserMailHelper,
|
||||||
FederatedFileSharingFactory $federatedFileSharingFactory,
|
FederatedFileSharingFactory $federatedFileSharingFactory,
|
||||||
ISecureRandom $secureRandom) {
|
ISecureRandom $secureRandom) {
|
||||||
parent::__construct($appName, $request);
|
parent::__construct($appName,
|
||||||
|
$request,
|
||||||
|
$userManager,
|
||||||
|
$config,
|
||||||
|
$groupManager,
|
||||||
|
$userSession,
|
||||||
|
$accountManager);
|
||||||
|
|
||||||
$this->userManager = $userManager;
|
|
||||||
$this->config = $config;
|
|
||||||
$this->appManager = $appManager;
|
$this->appManager = $appManager;
|
||||||
$this->groupManager = $groupManager;
|
|
||||||
$this->userSession = $userSession;
|
|
||||||
$this->accountManager = $accountManager;
|
|
||||||
$this->logger = $logger;
|
$this->logger = $logger;
|
||||||
$this->l10nFactory = $l10nFactory;
|
$this->l10nFactory = $l10nFactory;
|
||||||
$this->newUserMailHelper = $newUserMailHelper;
|
$this->newUserMailHelper = $newUserMailHelper;
|
||||||
|
|
Loading…
Reference in a new issue