diff options
author | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2020-04-17 09:26:00 +0300 |
---|---|---|
committer | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2020-04-17 09:26:00 +0300 |
commit | 111346e29d957c631bc7f892f597e3f805932435 (patch) | |
tree | 36b640f2097ce0a6e577adce010b2db045d63553 /lib/Controller | |
parent | 872e74b8ec7a67dd6db597ea4e742c3faa169c93 (diff) |
Fix app init & initialstate
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'lib/Controller')
-rw-r--r-- | lib/Controller/PageController.php | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/lib/Controller/PageController.php b/lib/Controller/PageController.php index add97dfb..4878e283 100644 --- a/lib/Controller/PageController.php +++ b/lib/Controller/PageController.php @@ -25,7 +25,7 @@ namespace OCA\Contacts\Controller; use OCP\AppFramework\Controller; use OCP\AppFramework\Http\TemplateResponse; -// use OCP\IInitialStateService; +use OCP\IInitialStateService; use OCP\IConfig; use OCP\L10N\IFactory; use OCP\IRequest; @@ -45,12 +45,12 @@ class PageController extends Controller { public function __construct(string $AppName, IRequest $request, IConfig $config, - // IInitialStateService $initialStateService, + IInitialStateService $initialStateService, IFactory $languageFactory) { parent::__construct($AppName, $request); $this->appName = $AppName; - // $this->initialStateService = $initialStateService; + $this->initialStateService = $initialStateService; $this->languageFactory = $languageFactory; $this->config = $config; } @@ -64,12 +64,9 @@ class PageController extends Controller { public function index(): TemplateResponse { $locales = $this->languageFactory->findAvailableLocales(); $defaultProfile = $this->config->getAppValue($this->appName, 'defaultProfile', 'HOME'); - // TODO: use initialStateService once min-version is 16! - // $this->initialStateService->provideInitialState($this->appName, 'locales', $locales); - // $this->initialStateService->provideInitialState($this->appName, 'defaultProfile', $defaultProfile); - return new TemplateResponse( - 'contacts', - 'main', - ['locales' => json_encode($locales), 'defaultProfile'=> json_encode($defaultProfile)]); // templates/main.php + + $this->initialStateService->provideInitialState($this->appName, 'locales', $locales); + $this->initialStateService->provideInitialState($this->appName, 'defaultProfile', $defaultProfile); + return new TemplateResponse($this->appName, 'main'); } } |