Merge pull request #3288 from appwrite/refactor-home

Refactor `home.php`
This commit is contained in:
Torsten Dittmann
2022-05-31 11:21:27 +02:00
committed by GitHub
+18 -31
View File
@@ -1,11 +1,13 @@
<?php
use Appwrite\Utopia\View;
use Appwrite\Utopia\Response;
use Utopia\App;
use Utopia\Config\Config;
use Utopia\Database\Database;
use Utopia\Database\Document;
App::init(function ($layout) {
/** @var Appwrite\Utopia\View $layout */
App::init(function (View $layout) {
$header = new View(__DIR__.'/../../views/home/comps/header.phtml');
$footer = new View(__DIR__.'/../../views/home/comps/footer.phtml');
@@ -24,9 +26,7 @@ App::init(function ($layout) {
;
}, ['layout'], 'home');
App::shutdown(function ($response, $layout) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Utopia\View $layout */
App::shutdown(function (Response $response, View $layout) {
$response->html($layout->render());
}, ['response', 'layout'], 'home');
@@ -38,10 +38,7 @@ App::get('/')
->inject('response')
->inject('dbForConsole')
->inject('project')
->action(function ($response, $dbForConsole, $project) {
/** @var Appwrite\Utopia\Response $response */
/** @var Utopia\Database\Database $dbForConsole */
/** @var Utopia\Database\Document $project */
->action(function (Response $response, Database $dbForConsole, Document $project) {
$response
->addHeader('Cache-Control', 'no-store, no-cache, must-revalidate, max-age=0')
@@ -69,8 +66,7 @@ App::get('/auth/signin')
->label('permission', 'public')
->label('scope', 'home')
->inject('layout')
->action(function ($layout) {
/** @var Appwrite\Utopia\View $layout */
->action(function (View $layout) {
$page = new View(__DIR__.'/../../views/home/auth/signin.phtml');
@@ -88,8 +84,8 @@ App::get('/auth/signup')
->label('permission', 'public')
->label('scope', 'home')
->inject('layout')
->action(function ($layout) {
/** @var Appwrite\Utopia\View $layout */
->action(function (View $layout) {
$page = new View(__DIR__.'/../../views/home/auth/signup.phtml');
$page
@@ -106,8 +102,7 @@ App::get('/auth/recovery')
->label('permission', 'public')
->label('scope', 'home')
->inject('layout')
->action(function ($layout) {
/** @var Appwrite\Utopia\View $layout */
->action(function (View $layout) {
$page = new View(__DIR__.'/../../views/home/auth/recovery.phtml');
@@ -125,8 +120,7 @@ App::get('/auth/confirm')
->label('permission', 'public')
->label('scope', 'home')
->inject('layout')
->action(function ($layout) {
/** @var Appwrite\Utopia\View $layout */
->action(function (View $layout) {
$page = new View(__DIR__.'/../../views/home/auth/confirm.phtml');
@@ -140,8 +134,7 @@ App::get('/auth/join')
->label('permission', 'public')
->label('scope', 'home')
->inject('layout')
->action(function ($layout) {
/** @var Appwrite\Utopia\View $layout */
->action(function (View $layout) {
$page = new View(__DIR__.'/../../views/home/auth/join.phtml');
@@ -155,8 +148,7 @@ App::get('/auth/recovery/reset')
->label('permission', 'public')
->label('scope', 'home')
->inject('layout')
->action(function ($layout) {
/** @var Appwrite\Utopia\View $layout */
->action(function (View $layout) {
$page = new View(__DIR__.'/../../views/home/auth/recovery/reset.phtml');
@@ -170,8 +162,7 @@ App::get('/auth/oauth2/success')
->label('permission', 'public')
->label('scope', 'home')
->inject('layout')
->action(function ($layout) {
/** @var Appwrite\Utopia\View $layout */
->action(function (View $layout) {
$page = new View(__DIR__.'/../../views/home/auth/oauth2.phtml');
@@ -188,8 +179,7 @@ App::get('/auth/magic-url')
->label('permission', 'public')
->label('scope', 'home')
->inject('layout')
->action(function ($layout) {
/** @var Appwrite\Utopia\View $layout */
->action(function (View $layout) {
$page = new View(__DIR__.'/../../views/home/auth/magicURL.phtml');
@@ -206,8 +196,7 @@ App::get('/auth/oauth2/failure')
->label('permission', 'public')
->label('scope', 'home')
->inject('layout')
->action(function ($layout) {
/** @var Appwrite\Utopia\View $layout */
->action(function (View $layout) {
$page = new View(__DIR__.'/../../views/home/auth/oauth2.phtml');
@@ -225,8 +214,7 @@ App::get('/error/:code')
->label('scope', 'home')
->param('code', null, new \Utopia\Validator\Numeric(), 'Valid status code number', false)
->inject('layout')
->action(function ($code, $layout) {
/** @var Appwrite\Utopia\View $layout */
->action(function (int $code, View $layout) {
$page = new View(__DIR__.'/../../views/error.phtml');
@@ -244,8 +232,7 @@ App::get('/versions')
->groups(['web', 'home'])
->label('scope', 'public')
->inject('response')
->action(function ($response) {
/** @var Appwrite\Utopia\Response $response */
->action(function (Response $response) {
$platforms = Config::getParam('platforms');