Skip to content

Commit 0491f07

Browse files
committed
refactoring
1 parent 1460327 commit 0491f07

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

App.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class App
2727
{
2828
//Default Controller
2929
protected $controllerName = 'home';
30+
protected $controllerNamespace = null;
3031

3132
//Default Method
3233
protected $methodName = 'index';
@@ -91,17 +92,16 @@ public function __construct($url = false)
9192
*/
9293
private function getMethod()
9394
{
94-
if (empty($this->url[0])) {
95+
if (empty($this->url[1])) {
9596
Debug::info('No Method Specified');
9697
return $this->methodName;
9798
}
98-
if (method_exists($this->controllerNameFull, $this->url[0])) {
99-
Debug::log("Modifying the method from $this->methodName to " . $this->url[0]);
100-
$out = array_shift($this->url);
101-
return strtolower($out);
99+
if (method_exists($this->controllerNamespace, $this->url[1])) {
100+
Debug::log("Modifying the method from $this->methodName to " . $this->url[1]);
101+
$this->methodName = strtolower($this->url[1]);
102+
return $this->methodName;
102103
}
103-
Debug::info('Method not found: ' . $this->url[0] . ', loading default.');
104-
array_shift($this->url);
104+
Debug::info('Method not found: ' . $this->url[1] . ', loading default.');
105105
return $this->methodName;
106106
}
107107

@@ -161,16 +161,17 @@ private function getController()
161161
private function updateController()
162162
{
163163
Debug::log("Modifying the controller from $this->controllerName to " . $this->url[0]);
164+
164165
}
165-
166+
166167
/**
167168
* This function Initiates the specified controller and
168169
* stores it as an object in controllerObject.
169170
*/
170171
private function loadController()
171172
{
172173
Debug::group("Initiating controller: $this->controllerName", 1);
173-
$this->controllerObject = new $this->controllerNameFull;
174+
$this->controllerObject = new $this->controllerNamespace;
174175
Debug::gend();
175176
}
176177

0 commit comments

Comments
 (0)