-
Notifications
You must be signed in to change notification settings - Fork 0
Class Application
Namespace:
Afoslt\Core
Parent:
-
Modifiers:
-
Afoslt framework application class.
-
RESPONSE_OK:0
Response code: everything is cool.
-
RESPONSE_ERROR_NO_MANIFEST:-1
Error code: application could not find manifest file.
-
RESPONSE_ERROR_NO_MATCH_ROUTE:404
Error code: application could not find routes matching with client's request.
-
RESPONSE_ERROR_NO_MATCH_ROUTE:-2
Error code: application could not find requested controller class.
-
RESPONSE_ERROR_ACTION_DOEST_EXISTS:-3
Error code: requested controller does not have requested action.
Modifiers:
staticprivate
Associative array of properties, that defines how application will initialize.
By default value for array stored in \config\manifest.php.
Default keys:
-
"routesDirectory"- Relative path to directory with routes files. _DEFAULT VALUE: _"config\\routes\\" -
"readGetPost"- Add keys and values from arrays $_GET and $_POST. _DEFAULT VALUE: _true -
"addKeywords"- Tells application to add keywords to controllers and actions name, when search for them. _DEFAULT VALUE: _true -
"controllersKeyword"- Keyword for Controllers. _DEFAULT VALUE: _"Controller" -
"actionsKeyword"- Keyword for Actions. _DEFAULT VALUE: _"Action" -
"build"- Defines work mode that application will use. _DEFAULT VALUE: _BUILD_DEBUG -
"startupSession"- Defines that session_start() will be called or not.
If default key is not defined in manifest file, application will use default value for that key.
Modifiers:
staticprivate
Associative array with arguments that application gets on startup from client request.
Arguments collect all values from GET, POST and Routes.
Priority of variables source:
- Routes
- POST
- GET
This priority list means that arguments with same keys will replace one another.
Modifiers:
private
Instance of class Router for instance of Application.
Modifiers:
staticprivate
Associative array for storing values from configurations files.
Modifiers:
staticprivate
Client's request to application. By default it's equals to $_SERVER_["REQUEST_URI"].
Modifiers:
staticprivate
Name of layout's file that will be used for view render.
Modifiers:
staticprotectedfinal
Setter for field $manifest.
Modifiers:
staticpublicfinal
Getter for field $arguments.
Modifiers:
staticpublicfinal
Add for field $arguments.
Adds new arguments with key $key and value $value.
SetRouter(Router $router): void
Modifiers:
protectedfinal
Setter for field $router.
GetRouter(): Router
Modifiers:
protectedfinal
Getter for field $router.
Modifiers:
staticprotectedfinal
Add for field $configuration.
Adds all keys their values from incoming array to configuration associative array of an applicaiton.
Modifiers:
staticpublicfinal
Getter for field $configuration.
Modifiers:
staticprivate
Setter for field $requestURI.
Modifiers:
staticpublicfinal
Getter for field $requestURI.
Modifiers:
staticprotectedfinal
Setter for field $layoutName.
Modifiers:
staticpublicfinal
Getter for field $layoutName.
Modifiers:
publicfinal
Constructor method of application class instance.
In first place constructor will define constants:
-
PATH_APPLICATION- path to application directory.
And load other constants defined in file Constants.php
Then constructor will call instance's methods in order:
LoadManifest()SetRouter()OnReady()Main()
After loading application manifest and before calling method OnReady() application will create instance of Router for reading avaible routes and client's request.
Modifiers:
private
Loading settings from manifest file by default path \config\manifest.php.
Modifiers:
private
Loading routes from all files in application routes directory. This method will also scan subdirectories for routes files.
Returns merge associative array of all associative arrays in routes directory.
Modifiers:
publicfinal
Loading configuration file from configuration folder. Configuration files must have php extension and return an associative array.
Path to configuration file must be relative to configurations directory.
Returns true if configuration from file loaded successfully.
Modifiers:
protected
Application errors handler.
Modifiers:
protected
This method will get result of controller's action method and show it to the client.
If action returns instance of View, this method will echo layout and view.
If action return array, application will encode it as JSON and return to the client.
Modifiers:
protected
This method executes before Main.
This is method where you can set up environment, before application will create controller and call action.
Modifiers:
private
Entry point of Application.
It will call method to read user's request and create controller.