emit typed event for user management
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
This commit is contained in:
parent
919a8d473b
commit
f959828616
|
@ -29,6 +29,7 @@ return array(
|
|||
'OCA\\Settings\\Controller\\TwoFactorSettingsController' => $baseDir . '/../lib/Controller/TwoFactorSettingsController.php',
|
||||
'OCA\\Settings\\Controller\\UsersController' => $baseDir . '/../lib/Controller/UsersController.php',
|
||||
'OCA\\Settings\\Controller\\WebAuthnController' => $baseDir . '/../lib/Controller/WebAuthnController.php',
|
||||
'OCA\\Settings\\Events\\BeforeTemplateRenderedEvent' => $baseDir . '/../lib/Events/BeforeTemplateRenderedEvent.php',
|
||||
'OCA\\Settings\\Hooks' => $baseDir . '/../lib/Hooks.php',
|
||||
'OCA\\Settings\\Mailer\\NewUserMailHelper' => $baseDir . '/../lib/Mailer/NewUserMailHelper.php',
|
||||
'OCA\\Settings\\Middleware\\SubadminMiddleware' => $baseDir . '/../lib/Middleware/SubadminMiddleware.php',
|
||||
|
|
|
@ -44,6 +44,7 @@ class ComposerStaticInitSettings
|
|||
'OCA\\Settings\\Controller\\TwoFactorSettingsController' => __DIR__ . '/..' . '/../lib/Controller/TwoFactorSettingsController.php',
|
||||
'OCA\\Settings\\Controller\\UsersController' => __DIR__ . '/..' . '/../lib/Controller/UsersController.php',
|
||||
'OCA\\Settings\\Controller\\WebAuthnController' => __DIR__ . '/..' . '/../lib/Controller/WebAuthnController.php',
|
||||
'OCA\\Settings\\Events\\BeforeTemplateRenderedEvent' => __DIR__ . '/..' . '/../lib/Events/BeforeTemplateRenderedEvent.php',
|
||||
'OCA\\Settings\\Hooks' => __DIR__ . '/..' . '/../lib/Hooks.php',
|
||||
'OCA\\Settings\\Mailer\\NewUserMailHelper' => __DIR__ . '/..' . '/../lib/Mailer/NewUserMailHelper.php',
|
||||
'OCA\\Settings\\Middleware\\SubadminMiddleware' => __DIR__ . '/..' . '/../lib/Middleware/SubadminMiddleware.php',
|
||||
|
|
|
@ -41,6 +41,7 @@ use OC\ForbiddenException;
|
|||
use OC\Security\IdentityProof\Manager;
|
||||
use OCA\FederatedFileSharing\FederatedShareProvider;
|
||||
use OCA\Settings\BackgroundJobs\VerifyUserData;
|
||||
use OCA\Settings\Events\BeforeTemplateRenderedEvent;
|
||||
use OCA\User_LDAP\User_Proxy;
|
||||
use OCP\App\IAppManager;
|
||||
use OCP\AppFramework\Controller;
|
||||
|
@ -49,6 +50,7 @@ use OCP\AppFramework\Http\JSONResponse;
|
|||
use OCP\AppFramework\Http\TemplateResponse;
|
||||
use OCP\BackgroundJob\IJobList;
|
||||
use OCP\Encryption\IManager;
|
||||
use OCP\EventDispatcher\IEventDispatcher;
|
||||
use OCP\IConfig;
|
||||
use OCP\IGroupManager;
|
||||
use OCP\IL10N;
|
||||
|
@ -87,23 +89,28 @@ class UsersController extends Controller {
|
|||
private $jobList;
|
||||
/** @var IManager */
|
||||
private $encryptionManager;
|
||||
/** @var IEventDispatcher */
|
||||
private $dispatcher;
|
||||
|
||||
|
||||
public function __construct(string $appName,
|
||||
IRequest $request,
|
||||
IUserManager $userManager,
|
||||
IGroupManager $groupManager,
|
||||
IUserSession $userSession,
|
||||
IConfig $config,
|
||||
bool $isAdmin,
|
||||
IL10N $l10n,
|
||||
IMailer $mailer,
|
||||
IFactory $l10nFactory,
|
||||
IAppManager $appManager,
|
||||
AccountManager $accountManager,
|
||||
Manager $keyManager,
|
||||
IJobList $jobList,
|
||||
IManager $encryptionManager) {
|
||||
public function __construct(
|
||||
string $appName,
|
||||
IRequest $request,
|
||||
IUserManager $userManager,
|
||||
IGroupManager $groupManager,
|
||||
IUserSession $userSession,
|
||||
IConfig $config,
|
||||
bool $isAdmin,
|
||||
IL10N $l10n,
|
||||
IMailer $mailer,
|
||||
IFactory $l10nFactory,
|
||||
IAppManager $appManager,
|
||||
AccountManager $accountManager,
|
||||
Manager $keyManager,
|
||||
IJobList $jobList,
|
||||
IManager $encryptionManager,
|
||||
IEventDispatcher $dispatcher
|
||||
) {
|
||||
parent::__construct($appName, $request);
|
||||
$this->userManager = $userManager;
|
||||
$this->groupManager = $groupManager;
|
||||
|
@ -118,6 +125,7 @@ class UsersController extends Controller {
|
|||
$this->keyManager = $keyManager;
|
||||
$this->jobList = $jobList;
|
||||
$this->encryptionManager = $encryptionManager;
|
||||
$this->dispatcher = $dispatcher;
|
||||
}
|
||||
|
||||
|
||||
|
@ -224,7 +232,9 @@ class UsersController extends Controller {
|
|||
$quotaPreset = $this->parseQuotaPreset($this->config->getAppValue('files', 'quota_preset', '1 GB, 5 GB, 10 GB'));
|
||||
$defaultQuota = $this->config->getAppValue('files', 'default_quota', 'none');
|
||||
|
||||
\OC::$server->getEventDispatcher()->dispatch('OC\Settings\Users::loadAdditionalScripts');
|
||||
$event = new BeforeTemplateRenderedEvent();
|
||||
$this->dispatcher->dispatch('OC\Settings\Users::loadAdditionalScripts', $event);
|
||||
$this->dispatcher->dispatchTyped($event);
|
||||
|
||||
/* LANGUAGES */
|
||||
$languages = $this->l10nFactory->getLanguages();
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* @copyright Copyright (c) 2020 Arthur Schiwon <blizzz@arthur-schiwon.de>
|
||||
*
|
||||
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OCA\Settings\Events;
|
||||
|
||||
use OCP\EventDispatcher\Event;
|
||||
|
||||
class BeforeTemplateRenderedEvent extends Event {
|
||||
}
|
|
@ -36,6 +36,7 @@ use OCP\AppFramework\Http;
|
|||
use OCP\BackgroundJob\IJobList;
|
||||
use OCP\Encryption\IEncryptionModule;
|
||||
use OCP\Encryption\IManager;
|
||||
use OCP\EventDispatcher\IEventDispatcher;
|
||||
use OCP\IAvatarManager;
|
||||
use OCP\IConfig;
|
||||
use OCP\IGroupManager;
|
||||
|
@ -55,7 +56,6 @@ use OCP\Security\ISecureRandom;
|
|||
* @package Tests\Settings\Controller
|
||||
*/
|
||||
class UsersControllerTest extends \Test\TestCase {
|
||||
|
||||
/** @var IGroupManager|\PHPUnit\Framework\MockObject\MockObject */
|
||||
private $groupManager;
|
||||
/** @var IUserManager|\PHPUnit\Framework\MockObject\MockObject */
|
||||
|
@ -90,6 +90,8 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
private $encryptionManager;
|
||||
/** @var IEncryptionModule | \PHPUnit\Framework\MockObject\MockObject */
|
||||
private $encryptionModule;
|
||||
/** @var IEventDispatcher|\PHPUnit\Framework\MockObject\MockObject */
|
||||
private $dispatcher;
|
||||
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
@ -106,6 +108,7 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
$this->securityManager = $this->getMockBuilder(\OC\Security\IdentityProof\Manager::class)->disableOriginalConstructor()->getMock();
|
||||
$this->jobList = $this->createMock(IJobList::class);
|
||||
$this->encryptionManager = $this->createMock(IManager::class);
|
||||
$this->dispatcher = $this->createMock(IEventDispatcher::class);
|
||||
|
||||
$this->l->method('t')
|
||||
->willReturnCallback(function ($text, $parameters = []) {
|
||||
|
@ -140,7 +143,8 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
$this->accountManager,
|
||||
$this->securityManager,
|
||||
$this->jobList,
|
||||
$this->encryptionManager
|
||||
$this->encryptionManager,
|
||||
$this->dispatcher
|
||||
);
|
||||
} else {
|
||||
return $this->getMockBuilder(UsersController::class)
|
||||
|
@ -160,7 +164,8 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
$this->accountManager,
|
||||
$this->securityManager,
|
||||
$this->jobList,
|
||||
$this->encryptionManager
|
||||
$this->encryptionManager,
|
||||
$this->dispatcher
|
||||
]
|
||||
)->setMethods($mockedMethods)->getMock();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue