-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.php
More file actions
81 lines (70 loc) · 2.49 KB
/
app.php
File metadata and controls
81 lines (70 loc) · 2.49 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
78
79
80
81
<?php
/**
* App.php
*
* This file parses any given url and separates it into controller,
* method, and data. This allows the application to direct the user
* to the desired location and provide the controller any additional
* information it may require to run.
*
* @version 1.0
*
* @author Joey Kimsey <JoeyKimsey@thetempusproject.com>
*
* @link https://TheTempusProject.com/Core
*
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
*/
namespace TempusProjectCore;
use TempusProjectCore\Classes\Debug;
use TempusProjectCore\Classes\Config;
use TempusProjectCore\Functions\Routes;
use TempusProjectCore\Classes\Input;
use TempusProjectCore\Core\TPCore;
class App extends TPCore
{
//Default Controller
protected $controllerName = 'home';
protected $controllerNamespace = null;
//Default Method
protected $methodName = 'index';
protected $path = null;
protected $directed = false;
protected $params = [];
protected $url = null;
/**
* The constructor handles the entire process of parsing the url,
* finding the controller/method, and calling the appropriate
* class/function for the application.
*
* @param string $url - A custom URL to be parsed to determine
* controller/method. (GET) url is used by
* default if none is provided
*/
public function __construct($url = false)
{
Debug::group('TPC Application');
Debug::log("Class Initiated: " . __CLASS__);
// Set the application url to be used
if ($url !== false) {
$this->directed = true;
}
$this->url = Routes::parseUrl($url);
// Set the controller default
$this->getController();
$this->setController();
// Ensure the controller is required
Debug::log("Requiring Controller: $this->controllerName");
require Routes::getLocation('controllers', $this->controllerName)->fullPath;;
// Find the Method
$this->methodName = $this->getMethod();
define('CORE_METHOD', $this->methodName);
/////////////////////////////////////////////////////////////////
// Load the appropriate Controller and Method which initiates //
// the dynamic part of the application. //
/////////////////////////////////////////////////////////////////
$this->loadController();
$this->loadMethod();
Debug::gend();
}
}