Completed
Branch master (d57d41)
by Vermeulen
03:02
created
src/BFW_init.php 2 patches
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -8,9 +8,9 @@  discard block
 block discarded – undo
8 8
 ob_start(); //Tamporisation du tampon de sortie html. Permet que le code html ne sorte qu'à la fin et non petit à petit (permet d'utiliser les fonctions changeant les headers ou cookie à n'importe quel moment par exemple)
9 9
 
10 10
 //Définition des chemins d'accès
11
-if(!isset($rootPath))
11
+if (!isset($rootPath))
12 12
 {
13
-    if(!isset($myVendorName))
13
+    if (!isset($myVendorName))
14 14
     {
15 15
         $myVendorName = 'vendor';
16 16
     }
@@ -19,30 +19,30 @@  discard block
 block discarded – undo
19 19
 }
20 20
 
21 21
 //Fichier de config
22
-if(!isset($forceConfig) || (isset($forceConfig) && $forceConfig == false))
22
+if (!isset($forceConfig) || (isset($forceConfig) && $forceConfig == false))
23 23
 {
24 24
     require_once($rootPath.'configs/bfw_config.php');
25 25
 }
26 26
 //Fichier de config
27 27
 
28
-if((isset($noSession) && $noSession == false) || !isset($noSession))
28
+if ((isset($noSession) && $noSession == false) || !isset($noSession))
29 29
 { 
30 30
     session_set_cookie_params(0); //permet de detruire le cookie de session si le navigateur quitte
31 31
     session_start(); //Ouverture des sessions
32 32
 }
33 33
 
34 34
 //Class Loader
35
-if(!isset($loader))
35
+if (!isset($loader))
36 36
 {
37 37
     $loader = require($rootPath.'vendor/autoload.php');
38 38
     $loaderAddPsr4 = 'addPsr4';
39 39
 }
40 40
 
41
-if(!isset($loaderAddPsr4)) {$loaderAddPsr4 = 'addNamespace';} //Default of PSR4 library
41
+if (!isset($loaderAddPsr4)) {$loaderAddPsr4 = 'addNamespace'; } //Default of PSR4 library
42 42
 
43 43
 $loader->$loaderAddPsr4('controller\\', $rootPath.'controllers/');
44
-$loader->$loaderAddPsr4('modules\\',    $rootPath.'modules/');
45
-$loader->$loaderAddPsr4('modeles\\',    $rootPath.'modeles/');
44
+$loader->$loaderAddPsr4('modules\\', $rootPath.'modules/');
45
+$loader->$loaderAddPsr4('modeles\\', $rootPath.'modeles/');
46 46
 //Class Loader
47 47
 
48 48
 //Instancie la classe Kernel
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 $modulesToLoad = array();
62 62
 
63 63
 //SQL
64
-if($bd_enabled)
64
+if ($bd_enabled)
65 65
 {
66 66
     $modulesToLoad['bd'] = array('name' => $bd_module, 'action' => 'load');
67 67
 }
@@ -72,32 +72,32 @@  discard block
 block discarded – undo
72 72
 //Controller
73 73
 $modulesToLoad['ctr'] = array('name' => $ctr_module, 'action' => 'test');
74 74
 
75
-foreach($modulesToLoad as $key => $moduleLoad)
75
+foreach ($modulesToLoad as $key => $moduleLoad)
76 76
 {
77
-    if(!empty($moduleLoad['name']))
77
+    if (!empty($moduleLoad['name']))
78 78
     {
79 79
         $pathToModule = $rootPath.'modules/'.$moduleLoad['name'];
80
-        if(empty($pathToModule))
80
+        if (empty($pathToModule))
81 81
         {
82 82
             continue;
83 83
         }
84 84
         
85
-        if(is_link($pathToModule))
85
+        if (is_link($pathToModule))
86 86
         {
87 87
             $pathToModule = readlink($pathToModule);
88 88
             
89
-            if(file_exists($pathToModule.'/bfw_modules_info.php'))
89
+            if (file_exists($pathToModule.'/bfw_modules_info.php'))
90 90
             {
91 91
                 require_once($pathToModule.'/bfw_modules_info.php');
92 92
                 
93
-                if(!empty($modulePath))
93
+                if (!empty($modulePath))
94 94
                 {
95 95
                     $pathToModule .= '/'.$modulePath;
96 96
                 }
97 97
             }
98 98
         }
99 99
         
100
-        if(!file_exists($pathToModule.'/kernel_init.php'))
100
+        if (!file_exists($pathToModule.'/kernel_init.php'))
101 101
         {
102 102
             define('kernelModuleLoad_'.$key.'_test', false);
103 103
             throw new \Exception('Module '.$moduleLoad['name'].' not found.');
@@ -106,13 +106,13 @@  discard block
 block discarded – undo
106 106
         define('kernelModuleLoad_'.$key.'_test', true);
107 107
         define('kernelModuleLoad_'.$key.'_path', $pathToModule.'/kernel_init.php');
108 108
         
109
-        if($moduleLoad['action'] == 'load')
109
+        if ($moduleLoad['action'] == 'load')
110 110
         {
111 111
             require_once($pathToModule.'/kernel_init.php');
112 112
         }
113 113
     }
114 114
     
115
-    if(!defined('kernelModuleLoad_'.$key.'_test'))
115
+    if (!defined('kernelModuleLoad_'.$key.'_test'))
116 116
     {
117 117
         define('kernelModuleLoad_'.$key.'_test', false);
118 118
     }
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 
122 122
 //Serveur memcache (permet de stocker des infos direct sur la ram avec ou sans limite dans le temps)
123 123
 $Memcache = null;
124
-if($memcache_enabled === true)
124
+if ($memcache_enabled === true)
125 125
 {
126 126
     $Memcache = new BFW\Ram($memcache_host, $memcache_port);
127 127
 }
@@ -145,30 +145,30 @@  discard block
 block discarded – undo
145 145
  */
146 146
 define('modulesLoadTime_EndInit', 'endInit');
147 147
 
148
-if(file_exists($rootPath.'modules'))
148
+if (file_exists($rootPath.'modules'))
149 149
 {
150 150
     $dir = opendir($rootPath.'modules');
151 151
     $dir_arr = array('.', '..', '.htaccess');
152 152
     
153
-    while(false !== ($moduleName = readdir($dir)))
153
+    while (false !== ($moduleName = readdir($dir)))
154 154
     {
155 155
         $path = $rootPath.'modules/'.$moduleName;
156
-        if(is_link($path)) {$path = readlink($path);}
156
+        if (is_link($path)) {$path = readlink($path); }
157 157
         
158 158
         //Si le fichier existe, on inclus le fichier principal du module
159
-        if(file_exists($path.'/module.json'))
159
+        if (file_exists($path.'/module.json'))
160 160
         {
161 161
             $Modules->newFromJson($path);
162 162
         }
163
-        elseif(file_exists($path.'/'.$moduleName.'.php'))
163
+        elseif (file_exists($path.'/'.$moduleName.'.php'))
164 164
         {
165 165
             require_once($path.'/'.$moduleName.'.php');
166 166
             $Modules->addPath($moduleName, $path);
167 167
         }
168
-        else {continue;}
168
+        else {continue; }
169 169
         
170 170
         $moduleInfos = $Modules->getModuleInfos($moduleName);
171
-        if(!file_exists($path.'/'.$moduleInfos['runFile']))
171
+        if (!file_exists($path.'/'.$moduleInfos['runFile']))
172 172
         {
173 173
             $Modules->loaded($moduleName);
174 174
         }
@@ -178,14 +178,14 @@  discard block
 block discarded – undo
178 178
 }
179 179
 
180 180
 $modulesToLoad = $Modules->listToLoad(modulesLoadTime_Module);
181
-if(is_array($modulesToLoad) && count($modulesToLoad) > 0)
181
+if (is_array($modulesToLoad) && count($modulesToLoad) > 0)
182 182
 {
183
-    foreach($modulesToLoad as $moduleToLoad)
183
+    foreach ($modulesToLoad as $moduleToLoad)
184 184
     {
185 185
         $infos = $Modules->getModuleInfos($moduleToLoad);
186 186
         $path = $infos['path'];
187 187
         
188
-        if(file_exists($path.'/'.$infos['runFile']))
188
+        if (file_exists($path.'/'.$infos['runFile']))
189 189
         {
190 190
             $Modules->loaded($moduleToLoad);
191 191
             require_once($path.'/'.$infos['runFile']);
@@ -200,14 +200,14 @@  discard block
 block discarded – undo
200 200
 
201 201
 //Chargement des modules
202 202
 $modulesToLoad = $Modules->listToLoad(modulesLoadTime_Visiteur);
203
-if(is_array($modulesToLoad) && count($modulesToLoad) > 0)
203
+if (is_array($modulesToLoad) && count($modulesToLoad) > 0)
204 204
 {
205
-    foreach($modulesToLoad as $moduleToLoad)
205
+    foreach ($modulesToLoad as $moduleToLoad)
206 206
     {
207 207
         $infos = $Modules->getModuleInfos($moduleToLoad);
208 208
         $path = $infos['path'];
209 209
         
210
-        if(file_exists($path.'/'.$infos['runFile']))
210
+        if (file_exists($path.'/'.$infos['runFile']))
211 211
         {
212 212
             $Modules->loaded($moduleToLoad);
213 213
             require_once($path.'/'.$infos['runFile']);
@@ -250,14 +250,14 @@  discard block
 block discarded – undo
250 250
 
251 251
 //Chargement des modules
252 252
 $modulesToLoad = $Modules->listToLoad(modulesLoadTime_EndInit);
253
-if(is_array($modulesToLoad) && count($modulesToLoad) > 0)
253
+if (is_array($modulesToLoad) && count($modulesToLoad) > 0)
254 254
 {
255
-    foreach($modulesToLoad as $moduleToLoad)
255
+    foreach ($modulesToLoad as $moduleToLoad)
256 256
     {
257 257
         $infos = $Modules->getModuleInfos($moduleToLoad);
258 258
         $path = $infos['path'];
259 259
         
260
-        if(file_exists($path.'/'.$infos['runFile']))
260
+        if (file_exists($path.'/'.$infos['runFile']))
261 261
         {
262 262
             $Modules->loaded($moduleToLoad);
263 263
             require_once($path.'/'.$infos['runFile']);
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -159,13 +159,11 @@
 block discarded – undo
159 159
         if(file_exists($path.'/module.json'))
160 160
         {
161 161
             $Modules->newFromJson($path);
162
-        }
163
-        elseif(file_exists($path.'/'.$moduleName.'.php'))
162
+        } elseif(file_exists($path.'/'.$moduleName.'.php'))
164 163
         {
165 164
             require_once($path.'/'.$moduleName.'.php');
166 165
             $Modules->addPath($moduleName, $path);
167
-        }
168
-        else {continue;}
166
+        } else {continue;}
169 167
         
170 168
         $moduleInfos = $Modules->getModuleInfos($moduleName);
171 169
         if(!file_exists($path.'/'.$moduleInfos['runFile']))
Please login to merge, or discard this patch.