-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
executable file
·77 lines (70 loc) · 2.28 KB
/
index.php
File metadata and controls
executable file
·77 lines (70 loc) · 2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
namespace App;
require( './_/__loader.php' );
use App\modules\AppTheme\AppTheme;
use App\modules\http\AppEnv\AppEnv;
use App\modules\AppPacker\AppPacker;
use App\modules\http\AppRouter\AppRouter;
use App\modules\http\AppGlobal\AppGlobal;
/**
*
* here we are starting the
* route manager
*/
AppPacker::startRoutes();
/**
* when we receive a request in the
* first step we have to create
* the database instance
*/
AppEnv::initDB();
/**
*
* to allow origin of request
* to acces to the cms
*/
AppGlobal::header( 'Access-Control-Allow-Origin', implode( ', ', [
'http://localhost',
'http://127.0.0.1'
] ) );
/**
*
* now we can resolve non derectly
* defined routes
*/
AppRouter::addMiddleWare( function( AppGlobal $global ) {
$configs = AppPacker::getConfigs( '__routes' );
foreach ( $configs as $sub_path => $data ) {
if ( $sub_path === $global->getPath() ) {
if ( is_string( $data ) ) {
AppPacker::render( $data );
$global->send();
} elseif( is_array( $data ) ) {
if ( array_key_exists( 'view', $data ) && is_string( $data[ 'view' ] ) ) {
$list = [ ];
if ( array_key_exists( 'params', $data ) AND is_array( $data[ 'params' ] ) ) {
$list = $data[ 'params' ];
if ( array_key_exists( 'theme', $data ) AND is_string( $data[ 'theme' ] ) ) {
AppPacker::renderThemeView( $data[ 'theme' ], $data[ 'view' ], $list );
$global->send();
}
}
AppPacker::render( $data[ 'view' ], $list );
$global->send();
}
}
}
}
} );
/**
*
* this function will add a
* middle ware to manage themes
*/
AppTheme::addThemeMiddleWare();
/**
*
* here we are resolving the
* route
*/
AppEnv::resolve();