diff options
author | Joas Schilling <coding@schilljs.com> | 2018-03-27 11:05:36 +0200 |
---|---|---|
committer | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2018-04-05 17:11:41 +0200 |
commit | 348171f311adb2758ad4c4de98d151569bec2d7a (patch) | |
tree | 3118ed5f8bbc1163fc6f778712d08d940e9b3388 | |
parent | 762002ec2eead8e282b671473a92c597a65b75e9 (diff) | |
download | nextcloud-server-348171f311adb2758ad4c4de98d151569bec2d7a.tar.gz nextcloud-server-348171f311adb2758ad4c4de98d151569bec2d7a.zip |
Use abstract subclass so members can be defined
Signed-off-by: Joas Schilling <coding@schilljs.com>
-rw-r--r-- | apps/provisioning_api/composer/composer/autoload_classmap.php | 2 | ||||
-rw-r--r-- | apps/provisioning_api/composer/composer/autoload_static.php | 2 | ||||
-rw-r--r-- | apps/provisioning_api/lib/Controller/AUserData.php (renamed from apps/provisioning_api/lib/Controller/UserDataTrait.php) | 50 | ||||
-rw-r--r-- | apps/provisioning_api/lib/Controller/GroupsController.php | 33 | ||||
-rw-r--r-- | apps/provisioning_api/lib/Controller/UsersController.php | 30 |
5 files changed, 63 insertions, 54 deletions
diff --git a/apps/provisioning_api/composer/composer/autoload_classmap.php b/apps/provisioning_api/composer/composer/autoload_classmap.php index 360fd409210..760eae82978 100644 --- a/apps/provisioning_api/composer/composer/autoload_classmap.php +++ b/apps/provisioning_api/composer/composer/autoload_classmap.php @@ -7,10 +7,10 @@ $baseDir = $vendorDir; return array( '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\\AppsController' => $baseDir . '/../lib/Controller/AppsController.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\\FederatedFileSharingFactory' => $baseDir . '/../lib/FederatedFileSharingFactory.php', 'OCA\\Provisioning_API\\Middleware\\Exceptions\\NotSubAdminException' => $baseDir . '/../lib/Middleware/Exceptions/NotSubAdminException.php', diff --git a/apps/provisioning_api/composer/composer/autoload_static.php b/apps/provisioning_api/composer/composer/autoload_static.php index 22fea99fa90..ccd4d54dccf 100644 --- a/apps/provisioning_api/composer/composer/autoload_static.php +++ b/apps/provisioning_api/composer/composer/autoload_static.php @@ -22,10 +22,10 @@ class ComposerStaticInitProvisioning_API public static $classMap = array ( '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\\AppsController' => __DIR__ . '/..' . '/../lib/Controller/AppsController.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\\FederatedFileSharingFactory' => __DIR__ . '/..' . '/../lib/FederatedFileSharingFactory.php', 'OCA\\Provisioning_API\\Middleware\\Exceptions\\NotSubAdminException' => __DIR__ . '/..' . '/../lib/Middleware/Exceptions/NotSubAdminException.php', diff --git a/apps/provisioning_api/lib/Controller/UserDataTrait.php b/apps/provisioning_api/lib/Controller/AUserData.php index ea481cb65fd..2b209067cee 100644 --- a/apps/provisioning_api/lib/Controller/UserDataTrait.php +++ b/apps/provisioning_api/lib/Controller/AUserData.php @@ -22,14 +22,54 @@ declare(strict_types=1); namespace OCA\Provisioning_API\Controller; use OC\Accounts\AccountManager; -use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\OCS\OCSException; use OCP\AppFramework\OCS\OCSNotFoundException; -use OCP\AppFramework\OCS\OCSForbiddenException; +use OCP\AppFramework\OCSController; use OCP\Files\NotFoundException; 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 @@ -38,7 +78,7 @@ trait UserDataTrait { * @return array * @throws OCSException */ - public function getUserData(string $userId): array { + protected function getUserData(string $userId): array { $currentLoggedInUser = $this->userSession->getUser(); $data = []; @@ -134,4 +174,4 @@ trait UserDataTrait { return $data; } -}
\ No newline at end of file +} diff --git a/apps/provisioning_api/lib/Controller/GroupsController.php b/apps/provisioning_api/lib/Controller/GroupsController.php index 7c917fa6c98..c2958bc4778 100644 --- a/apps/provisioning_api/lib/Controller/GroupsController.php +++ b/apps/provisioning_api/lib/Controller/GroupsController.php @@ -33,7 +33,6 @@ use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\OCS\OCSException; use OCP\AppFramework\OCS\OCSNotFoundException; use OCP\AppFramework\OCS\OCSForbiddenException; -use OCP\AppFramework\OCSController; use OCP\IConfig; use OCP\IGroup; use OCP\IGroupManager; @@ -43,24 +42,7 @@ use OCP\IUserManager; use OCP\IUserSession; use OCP\IUser; -class GroupsController extends OCSController { - - use UserDataTrait; - - /** @var IUserManager */ - private $userManager; - - /** @var IGroupManager */ - private $groupManager; - - /** @var IUserSession */ - private $userSession; - - /** @var IConfig */ - private $config; - - /** @var AccountManager */ - private $accountManager; +class GroupsController extends AUserData { /** @var ILogger */ private $logger; @@ -84,13 +66,14 @@ class GroupsController extends OCSController { IUserSession $userSession, AccountManager $accountManager, 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; } diff --git a/apps/provisioning_api/lib/Controller/UsersController.php b/apps/provisioning_api/lib/Controller/UsersController.php index 62c234013b5..1a710b592d2 100644 --- a/apps/provisioning_api/lib/Controller/UsersController.php +++ b/apps/provisioning_api/lib/Controller/UsersController.php @@ -35,14 +35,11 @@ namespace OCA\Provisioning_API\Controller; use OC\Accounts\AccountManager; use OC\HintException; use OC\Settings\Mailer\NewUserMailHelper; -use OC_Helper; use OCA\Provisioning_API\FederatedFileSharingFactory; use OCP\App\IAppManager; use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\OCS\OCSException; use OCP\AppFramework\OCS\OCSForbiddenException; -use OCP\AppFramework\OCSController; -use OCP\Files\NotFoundException; use OCP\IConfig; use OCP\IGroup; use OCP\IGroupManager; @@ -53,22 +50,10 @@ use OCP\IUserSession; use OCP\L10N\IFactory; use OCP\Security\ISecureRandom; -class UsersController extends OCSController { +class UsersController extends AUserData { - use UserDataTrait; - - /** @var IUserManager */ - private $userManager; - /** @var IConfig */ - private $config; /** @var IAppManager */ 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 */ private $logger; /** @var IFactory */ @@ -108,14 +93,15 @@ class UsersController extends OCSController { NewUserMailHelper $newUserMailHelper, FederatedFileSharingFactory $federatedFileSharingFactory, 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->groupManager = $groupManager; - $this->userSession = $userSession; - $this->accountManager = $accountManager; $this->logger = $logger; $this->l10nFactory = $l10nFactory; $this->newUserMailHelper = $newUserMailHelper; |