namespace OCA\Settings\Settings\Personal\Security;
+use OCP\AppFramework\Services\IInitialState;
use OCP\IUserSession;
use function array_map;
use OC\Authentication\Exceptions\InvalidTokenException;
use OC\Authentication\Token\IProvider as IAuthTokenProvider;
use OC\Authentication\Token\IToken;
use OCP\AppFramework\Http\TemplateResponse;
-use OCP\IInitialStateService;
use OCP\ISession;
use OCP\Session\Exceptions\SessionNotAvailableException;
use OCP\Settings\ISettings;
/** @var ISession */
private $session;
- /** @var IInitialStateService */
- private $initialStateService;
+ /** @var IInitialState */
+ private $initialState;
/** @var string|null */
private $uid;
public function __construct(IAuthTokenProvider $tokenProvider,
ISession $session,
IUserSession $userSession,
- IInitialStateService $initialStateService,
+ IInitialState $initialState,
?string $UserId) {
$this->tokenProvider = $tokenProvider;
$this->session = $session;
- $this->initialStateService = $initialStateService;
+ $this->initialState = $initialState;
$this->uid = $UserId;
$this->userSession = $userSession;
}
public function getForm(): TemplateResponse {
- $this->initialStateService->provideInitialState(
- 'settings',
+ $this->initialState->provideInitialState(
'app_tokens',
$this->getAppTokens()
);
- $this->initialStateService->provideInitialState(
- 'settings',
+ $this->initialState->provideInitialState(
'can_create_app_token',
$this->userSession->getImpersonatingUserID() === null
);
use OC\Authentication\Token\IProvider as IAuthTokenProvider;
use OCA\Settings\Settings\Personal\Security\Authtokens;
use OCP\AppFramework\Http\TemplateResponse;
-use OCP\IInitialStateService;
+use OCP\AppFramework\Services\IInitialState;
use OCP\ISession;
use OCP\IUserSession;
use PHPUnit\Framework\MockObject\MockObject;
/** @var IUserSession|MockObject */
private $userSession;
- /** @var IInitialStateService|MockObject */
- private $initialStateService;
+ /** @var IInitialState|MockObject */
+ private $initialState;
/** @var string */
private $uid;
$this->authTokenProvider = $this->createMock(IAuthTokenProvider::class);
$this->session = $this->createMock(ISession::class);
$this->userSession = $this->createMock(IUserSession::class);
- $this->initialStateService = $this->createMock(IInitialStateService::class);
+ $this->initialState = $this->createMock(IInitialState::class);
$this->uid = 'test123';
$this->section = new Authtokens(
$this->authTokenProvider,
$this->session,
$this->userSession,
- $this->initialStateService,
+ $this->initialState,
$this->uid
);
}
->method('getToken')
->with('session123')
->willReturn($sessionToken);
- $this->initialStateService->expects($this->at(0))
+ $this->initialState->expects($this->at(0))
->method('provideInitialState')
- ->with('settings', 'app_tokens', [
+ ->with('app_tokens', [
[
'id' => 100,
'name' => null,
],
]);
- $this->initialStateService->expects($this->at(1))
+ $this->initialState->expects($this->at(1))
->method('provideInitialState')
- ->with('settings', 'can_create_app_token', true);
+ ->with('can_create_app_token', true);
$form = $this->section->getForm();
use OCP\Files\Folder;
use OCP\Files\IAppData;
use OCP\Group\ISubAdmin;
+use OCP\IConfig;
+use OCP\IInitialStateService;
use OCP\IL10N;
use OCP\ILogger;
use OCP\INavigationManager;
return $dispatcher;
});
- $this->registerAlias(IAppConfig::class, OC\AppFramework\Services\AppConfig::class);
- $this->registerAlias(IInitialState::class, OC\AppFramework\Services\InitialState::class);
+ $this->registerService(IAppConfig::class, function (SimpleContainer $c) {
+ return new OC\AppFramework\Services\AppConfig(
+ $c->query(IConfig::class),
+ $c->query('AppName')
+ );
+ });
+ $this->registerService(IInitialState::class, function (SimpleContainer $c) {
+ return new OC\AppFramework\Services\InitialState(
+ $c->query(IInitialStateService::class),
+ $c->query('AppName')
+ );
+ });
}
/**