|
|
|
@ -10,8 +10,10 @@ declare(strict_types = 1); |
|
|
|
namespace Project\Classes; |
|
|
|
namespace Project\Classes; |
|
|
|
|
|
|
|
|
|
|
|
use IOcornerstone\Framework\Http\HttpFactory; |
|
|
|
use IOcornerstone\Framework\Http\HttpFactory; |
|
|
|
use Psr\Http\Message\ServerRequestInterface; |
|
|
|
use Psr\Http\Message\{ |
|
|
|
use Psr\Http\Message\ResponseInterface; |
|
|
|
ServerRequestInterface, |
|
|
|
|
|
|
|
ResponseInterface, |
|
|
|
|
|
|
|
}; |
|
|
|
use IOcornerstone\Framework\{ |
|
|
|
use IOcornerstone\Framework\{ |
|
|
|
HtmlDocument, |
|
|
|
HtmlDocument, |
|
|
|
View, |
|
|
|
View, |
|
|
|
@ -26,6 +28,9 @@ class BaseController |
|
|
|
public $view; |
|
|
|
public $view; |
|
|
|
public $html; |
|
|
|
public $html; |
|
|
|
public $outputHTML; |
|
|
|
public $outputHTML; |
|
|
|
|
|
|
|
public $pdo; |
|
|
|
|
|
|
|
public $inputs; // Set by Inputs and used in Logic/Outputs |
|
|
|
|
|
|
|
public $logic; // Used in Logic for Outputs |
|
|
|
protected string $footer = ""; |
|
|
|
protected string $footer = ""; |
|
|
|
protected string $authors = ""; |
|
|
|
protected string $authors = ""; |
|
|
|
|
|
|
|
|
|
|
|
@ -43,6 +48,31 @@ class BaseController |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function autoWireIOL( |
|
|
|
|
|
|
|
string $root_folder, |
|
|
|
|
|
|
|
string $file, |
|
|
|
|
|
|
|
string $method = 'index', |
|
|
|
|
|
|
|
): ResponseInterface { |
|
|
|
|
|
|
|
$saferRootFolder = Common::getAlphaNumbric($root_folder, allow_dashes: true); |
|
|
|
|
|
|
|
$saferFile = Common::getAlphaNumbric($file, allow_dashes: true); |
|
|
|
|
|
|
|
$saferMethod = Common::getAlphaNumbric($method, allow_dashes: true); |
|
|
|
|
|
|
|
unset($root_folder); |
|
|
|
|
|
|
|
unset($file); |
|
|
|
|
|
|
|
unset($method); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$classNameIn = "\\Project\\Classes\\Inputs\\{$saferRootFolder}\\{$saferFile}"; |
|
|
|
|
|
|
|
$this->inputs = $classNameIn::$saferMethod($this->request); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Logic might not always exist, so check. |
|
|
|
|
|
|
|
$classNameLogic = "\\Project\\Classes\\Logic\\{$saferRootFolder}\\{$saferFile}"; |
|
|
|
|
|
|
|
if (method_exists($classNameLogic, $saferMethod)) { |
|
|
|
|
|
|
|
$classNameLogic::$saferMethod($this); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$classNameOut= "\\Project\\Classes\\Outputs\\{$saferRootFolder}\\{$saferFile}"; |
|
|
|
|
|
|
|
return $classNameOut::$saferMethod($this); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function returnResponse(string|array $body, int $status = 200, array $headers = []): ResponseInterface |
|
|
|
public function returnResponse(string|array $body, int $status = 200, array $headers = []): ResponseInterface |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (is_array($body)) { |
|
|
|
if (is_array($body)) { |
|
|
|
|