Skip to content

Commit

Permalink
Removed Controller::notImplemented(), return 404 instead
Browse files Browse the repository at this point in the history
  • Loading branch information
AliasIO committed Jul 18, 2013
1 parent 9c908ca commit 397c2eb
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 31 deletions.
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,6 @@ Actions are methods of the controller. A common example might be `edit` or
This will call the function `edit()` on `Blog` with `1` as the argument (the
id of the blog post to edit).

If the action doesn't exist `notImplemented()` will be called instead. This
will throw an exception by default but can be overridden.

The action name and arguments can be accessed through
`$this->app->getAction()` and `$this->app->getArgs()` respectively.

Expand Down Expand Up @@ -309,9 +306,6 @@ Recursively decode a previously encoded value to be rendered as HTML
* `index()`
Default action

* `notImplemented()`
Fallback action in case the called action doesn't exist


User contributed packages
-------------------------
Expand Down
12 changes: 10 additions & 2 deletions Swiftlet/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,18 @@ public function run()
if ( $method->isPublic() && !$method->isFinal() && !$method->isConstructor() ) {
$this->controller->{$this->action}();
} else {
$this->controller->notImplemented();
$this->controller = new Controllers\Error404($this, $this->view);

$this->view->name = 'error404';

$this->controller->index();
}
} else {
$this->controller->notImplemented();
$this->controller = new Controllers\Error404($this, $this->view);

$this->view->name = 'error404';

$this->controller->index();
}

$this->registerHook('actionAfter');
Expand Down
9 changes: 0 additions & 9 deletions Swiftlet/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,4 @@ public function __construct(Interfaces\App $app, Interfaces\View $view)
public function index()
{
}

/**
* Fallback in case action doesn't exist
* @throws Exception
*/
public function notImplemented()
{
throw new Exception('Action ' . $this->view->htmlEncode($this->app->getAction()) . ' not implemented in ' . get_called_class());
}
}
8 changes: 0 additions & 8 deletions Swiftlet/Controllers/Error404.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,4 @@ public function index()
header('Status: 404 Not Found');
}
}

/**
* Not implemented action
*/
public function notImplemented()
{
$this->index();
}
}
6 changes: 0 additions & 6 deletions Swiftlet/Interfaces/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,4 @@ public function __construct(App $app, View $view);
* Default action
*/
public function index();

/**
* Fallback in case action doesn't exist
* @throws Exception
*/
public function notImplemented();
}

0 comments on commit 397c2eb

Please sign in to comment.