Skip to content

Commit

Permalink
Controller->execute() has to return a View
Browse files Browse the repository at this point in the history
To make sure some answer is send to the client, `Controller`s now have to return a `View`
  • Loading branch information
felix-schindler committed Oct 27, 2022
1 parent f268d40 commit 7e44e96
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions Backend/Core/System/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ abstract class Controller

/**
* @var array<string,string[]> Required variables in the body of the request
*
* defined like this: ['POST' => ['param1', 'param2'], 'PATCH' => ['param3']]
* @example location defined like this: `['POST' => ['param1', 'param2'], 'PATCH' => ['param3']]`
*/
protected array $reqVar = [];

Expand All @@ -48,7 +47,7 @@ public function initRoutes(): void {
public function runExecute(array $params): void {
if (($code = $this->checkAccess()) === 200) {
$this->params = $params;
$this->execute();
$this->execute()->render();
} else {
(new ErrorView($code, str_contains(IO::path(), '/api/')))->render();
}
Expand All @@ -57,7 +56,7 @@ public function runExecute(array $params): void {
/**
* Main method of the controller
*/
abstract protected function execute(): void;
abstract protected function execute(): View;

/**
* Get a param from within the URL
Expand Down

0 comments on commit 7e44e96

Please sign in to comment.