Skip to content
This repository was archived by the owner on Oct 21, 2024. It is now read-only.

Controller not found #41

Open
wants to merge 2 commits into
base: version/1.x
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions b8/Application.php
Original file line number Diff line number Diff line change
@@ -66,6 +66,10 @@ public function handleRequest()

$action = lcfirst($this->toPhpName($this->route['action']));

if (!$this->controllerExists($this->route)) {
throw new NotFoundException('Route not found');
}

if (!$this->getController()->hasAction($action)) {
throw new NotFoundException('Controller ' . $this->toPhpName($this->route['controller']) . ' does not have action ' . $action);
}
@@ -79,9 +83,7 @@ public function handleRequest()
public function getController()
{
if (empty($this->controller)) {
$namespace = $this->toPhpName($this->route['namespace']);
$controller = $this->toPhpName($this->route['controller']);
$controllerClass = $this->config->get('b8.app.namespace') . '\\' . $namespace . '\\' . $controller . 'Controller';
$controllerClass = $this->getControllerClass($this->route);
$this->controller = $this->loadController($controllerClass);
}

@@ -97,13 +99,15 @@ protected function loadController($class)
}

protected function controllerExists($route)
{
return class_exists($this->getControllerClass($route));
}

protected function getControllerClass($route)
{
$namespace = $this->toPhpName($route['namespace']);
$controller = $this->toPhpName($route['controller']);

$controllerClass = $this->config->get('b8.app.namespace') . '\\' . $namespace . '\\' . $controller . 'Controller';

return class_exists($controllerClass);
return $this->config->get('b8.app.namespace') . '\\' . $namespace . '\\' . $controller . 'Controller';
}

public function isValidRoute($route)