| ... | ... |
@@ -4,12 +4,11 @@ namespace elanpl\L3; |
| 4 | 4 |
|
| 5 | 5 |
class Application{
|
| 6 | 6 |
public $Config; // L3 Config object |
| 7 |
- public $Request; // build from received HTTP request |
|
| 7 |
+ public $Request; // build from received HTTP request or created in L3 Config object |
|
| 8 | 8 |
public $Response; // response to be send |
| 9 | 9 |
public $Router; // routing engine |
| 10 | 10 |
public $Serialization; // serialization engine |
| 11 | 11 |
public $BaseDirectory; // directory root of the application |
| 12 |
- public $ConfigDirectory; // directory containing application configuration files |
|
| 13 | 12 |
public $ControllersDirectory; // subdirectory/namespace part added to controller class |
| 14 | 13 |
public $ViewsDirectory; // subdirectory to search for the view files |
| 15 | 14 |
public $ApplicationDirectory; // subdirectory/namespace part of the application |
| ... | ... |
@@ -20,6 +19,14 @@ class Application{
|
| 20 | 19 |
public function __construct($config){
|
| 21 | 20 |
//set L3 application config |
| 22 | 21 |
$this->Config = $config; |
| 22 |
+ // directory root of the application |
|
| 23 |
+ $this->BaseDirectory = $config->getBaseDirectory(); |
|
| 24 |
+ // subdirectory/namespace part added to controller class |
|
| 25 |
+ $this->ControllersDirectory = $config->getControllersDirectory(); |
|
| 26 |
+ // subdirectory to search for the view files |
|
| 27 |
+ $this->ViewsDirectory = $config->getViewsDirectory(); |
|
| 28 |
+ // subdirectory/namespace part of the application |
|
| 29 |
+ $this->ApplicationDirectory = $config->getApplicationDirectory(); |
|
| 23 | 30 |
//create request object |
| 24 | 31 |
$this->Request = $this->Config->getRequest(); |
| 25 | 32 |
//create router object |
| ... | ... |
@@ -43,23 +50,6 @@ class Application{
|
| 43 | 50 |
return $this->Router->link($name, $parameters); |
| 44 | 51 |
} |
| 45 | 52 |
|
| 46 |
- public function LoadApplicationConfiguration(){
|
|
| 47 |
- //include routing configuration |
|
| 48 |
- include_once($this->ConfigDirectory."routing.php"); |
|
| 49 |
- //include the application configuration |
|
| 50 |
- include_once($this->ConfigDirectory.'app.php'); |
|
| 51 |
- } |
|
| 52 |
- |
|
| 53 |
- public function LoadConfigFile($file){
|
|
| 54 |
- //include configuration file |
|
| 55 |
- return include_once($this->ConfigDirectory.$file); |
|
| 56 |
- } |
|
| 57 |
- |
|
| 58 |
- public function IncludeFromConfigDir($file){
|
|
| 59 |
- //include configuration file |
|
| 60 |
- return include($this->ConfigDirectory.$file); |
|
| 61 |
- } |
|
| 62 |
- |
|
| 63 | 53 |
/* |
| 64 | 54 |
//not need - PSR-4 autoload handles that |
| 65 | 55 |
function IncludeControler($Controller){
|
| ... | ... |
@@ -10,4 +10,20 @@ class Config{
|
| 10 | 10 |
public function getRouting(){
|
| 11 | 11 |
return new \app\config\routing(); |
| 12 | 12 |
} |
| 13 |
+ |
|
| 14 |
+ public function getBaseDirectory(){
|
|
| 15 |
+ return _L3_BASE_PATH; |
|
| 16 |
+ } |
|
| 17 |
+ |
|
| 18 |
+ public function getApplicationDirectory(){
|
|
| 19 |
+ return "app"; |
|
| 20 |
+ } |
|
| 21 |
+ |
|
| 22 |
+ public function getControllersDirectory(){
|
|
| 23 |
+ return "controllers"; |
|
| 24 |
+ } |
|
| 25 |
+ |
|
| 26 |
+ public function getViewsDirectory(){
|
|
| 27 |
+ return "views"; |
|
| 28 |
+ } |
|
| 13 | 29 |
} |
| 14 | 30 |
\ No newline at end of file |