From a632ceeb583b07da83fc118fdb4a8ab3df0dd0a9 Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Sat, 26 Dec 2020 19:02:50 +0200 Subject: [PATCH] Updated home controller --- app/controllers/web/home.php | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/app/controllers/web/home.php b/app/controllers/web/home.php index 5d5b0281c..5b4e9b731 100644 --- a/app/controllers/web/home.php +++ b/app/controllers/web/home.php @@ -41,16 +41,18 @@ App::get('/') ->groups(['web', 'home']) ->label('permission', 'public') ->label('scope', 'home') + ->inject('response') ->action(function ($response) { /** @var Appwrite\Utopia\Response $response */ $response->redirect('/auth/signin'); - }, ['response']); + }); App::get('/auth/signin') ->groups(['web', 'home']) ->label('permission', 'public') ->label('scope', 'home') + ->inject('layout') ->action(function ($layout) { /** @var Utopia\View $layout */ @@ -59,12 +61,13 @@ App::get('/auth/signin') $layout ->setParam('title', 'Sign In - '.APP_NAME) ->setParam('body', $page); - }, ['layout']); + }); App::get('/auth/signup') ->groups(['web', 'home']) ->label('permission', 'public') ->label('scope', 'home') + ->inject('layout') ->action(function ($layout) { /** @var Utopia\View $layout */ $page = new View(__DIR__.'/../../views/home/auth/signup.phtml'); @@ -72,12 +75,13 @@ App::get('/auth/signup') $layout ->setParam('title', 'Sign Up - '.APP_NAME) ->setParam('body', $page); - }, ['layout']); + }); App::get('/auth/recovery') ->groups(['web', 'home']) ->label('permission', 'public') ->label('scope', 'home') + ->inject('layout') ->action(function ($layout) { /** @var Utopia\View $layout */ @@ -86,12 +90,13 @@ App::get('/auth/recovery') $layout ->setParam('title', 'Password Recovery - '.APP_NAME) ->setParam('body', $page); - }, ['layout']); + }); App::get('/auth/confirm') ->groups(['web', 'home']) ->label('permission', 'public') ->label('scope', 'home') + ->inject('layout') ->action(function ($layout) { /** @var Utopia\View $layout */ @@ -100,12 +105,13 @@ App::get('/auth/confirm') $layout ->setParam('title', 'Account Confirmation - '.APP_NAME) ->setParam('body', $page); - }, ['layout']); + }); App::get('/auth/join') ->groups(['web', 'home']) ->label('permission', 'public') ->label('scope', 'home') + ->inject('layout') ->action(function ($layout) { /** @var Utopia\View $layout */ @@ -114,12 +120,13 @@ App::get('/auth/join') $layout ->setParam('title', 'Invitation - '.APP_NAME) ->setParam('body', $page); - }, ['layout']); + }); App::get('/auth/recovery/reset') ->groups(['web', 'home']) ->label('permission', 'public') ->label('scope', 'home') + ->inject('layout') ->action(function ($layout) { /** @var Utopia\View $layout */ @@ -128,12 +135,13 @@ App::get('/auth/recovery/reset') $layout ->setParam('title', 'Password Reset - '.APP_NAME) ->setParam('body', $page); - }, ['layout']); + }); App::get('/auth/oauth2/success') ->groups(['web', 'home']) ->label('permission', 'public') ->label('scope', 'home') + ->inject('layout') ->action(function ($layout) { /** @var Utopia\View $layout */ @@ -145,12 +153,13 @@ App::get('/auth/oauth2/success') ->setParam('header', []) ->setParam('footer', []) ; - }, ['layout']); + }); App::get('/auth/oauth2/failure') ->groups(['web', 'home']) ->label('permission', 'public') ->label('scope', 'home') + ->inject('layout') ->action(function ($layout) { /** @var Utopia\View $layout */ @@ -162,13 +171,14 @@ App::get('/auth/oauth2/failure') ->setParam('header', []) ->setParam('footer', []) ; - }, ['layout']); + }); App::get('/error/:code') ->groups(['web', 'home']) ->label('permission', 'public') ->label('scope', 'home') ->param('code', null, new \Utopia\Validator\Numeric(), 'Valid status code number', false) + ->inject('layout') ->action(function ($code, $layout) { /** @var Utopia\View $layout */ @@ -181,7 +191,7 @@ App::get('/error/:code') $layout ->setParam('title', 'Error'.' - '.APP_NAME) ->setParam('body', $page); - }, ['layout']); + }, ['']); App::get('/specs/:format') ->groups(['web', 'home']) @@ -190,6 +200,9 @@ App::get('/specs/:format') ->param('format', 'swagger2', new WhiteList(['swagger2', 'open-api3'], true), 'Spec format.', true) ->param('platform', APP_PLATFORM_CLIENT, new WhiteList([APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER, APP_PLATFORM_CONSOLE], true), 'Choose target platform.', true) ->param('tests', 0, function () {return new Range(0, 1);}, 'Include only test services.', true) + ->inject('utopia') + ->inject('request') + ->inject('response') ->action(function ($format, $platform, $tests, $utopia, $request, $response) { /** @var Utopia\App $utopia */ /** @var Utopia\Swoole\Request $request */ @@ -347,4 +360,4 @@ App::get('/specs/:format') $response ->json($specs->parse()); - }, ['utopia', 'request', 'response']); \ No newline at end of file + }); \ No newline at end of file