iol testing...

main
Robert 2 months ago
parent 6103aaf0d7
commit 81b5e0f2af
  1. 19
      src/bootstrap/safer_io.php
  2. 8
      src/classes/base_controller.php
  3. 4
      src/classes/html.php
  4. 6
      src/classes/view.php

@ -55,23 +55,32 @@ final class use_io {
*/ */
final class use_iol { final class use_iol {
public static function auto_wire( public static function auto_wire(
object $app,
string $root_folder, string $root_folder,
string $file, string $file,
string $method = 'index', string $method = 'index',
string $db_service= 'db_mocker' ?string $db_service= 'db_mocker'
) { ) {
new \CodeHydrater\enums\safer_io_enums(); // Auto load new \CodeHydrater\enums\safer_io_enums(); // Auto load
registry::set('db', \main_tts\registry::get('di')->get_service($db_service) ); if ($db_service !== null && !empty($db_service)) {
if (\main_tts\registry::get('di')->has($db_service)) {
registry::set('db', \main_tts\registry::get('di')->get_service($db_service) );
} else {
// set error
}
}
$class_name = "\\Project\\inputs\\{$root_folder}\\{$file}_in"; $class_name = "\\Project\\inputs\\{$root_folder}\\{$file}_in";
$input = $class_name::$method(); $input = $class_name::$method($app);
$class_name = "\\Project\\logic\\{$root_folder}\\{$file}_logic"; $class_name = "\\Project\\logic\\{$root_folder}\\{$file}_logic";
$class_name::$method($input); if (method_exists($class_name, $method)) {
$class_name::$method($app, $input);
}
$class_name = "\\Project\\outputs\\{$root_folder}\\{$file}_out"; $class_name = "\\Project\\outputs\\{$root_folder}\\{$file}_out";
return $class_name::$method($input); return $class_name::$method($app, $input);
} }
} }

@ -21,14 +21,14 @@ use \CodeHydrater\http\response as Response;
*/ */
class base_controller { class base_controller {
public static $params; // To keep Routes working... public static $params; // To keep Routes working...
protected $view; public $view;
protected $html; public $html;
protected string $footer = ""; protected string $footer = "";
protected string $authors = ""; protected string $authors = "";
public function __construct( public function __construct(
protected Request $request, public Request $request,
protected Response $response public Response $response
) { ) {
$this->view = new \CodeHydrater\view(); $this->view = new \CodeHydrater\view();
$this->html = new \CodeHydrater\html_document(); $this->html = new \CodeHydrater\html_document();

@ -70,7 +70,7 @@ final class html {
echo "{$nl}<table border='1' cellpadding='1' cellspacing='1'>{$nl}"; echo "{$nl}<table border='1' cellpadding='1' cellspacing='1'>{$nl}";
echo "\t<tr>{$nl}"; echo "\t<tr>{$nl}";
foreach($header_fields as $header_field) { foreach($header_fields as $header_field) {
$field = ($escape) ? \bs_tts\safer_io::h($header_field) : $header_field; $field = ($escape) ? \CodeHydrater\bootstrap\safer_io::h($header_field) : $header_field;
echo "\t\t<th>{$field}</th>{$nl}"; echo "\t\t<th>{$field}</th>{$nl}";
} }
echo "\t</tr>{$nl}"; echo "\t</tr>{$nl}";
@ -78,7 +78,7 @@ final class html {
foreach($fields as $field) { foreach($fields as $field) {
echo "\t<tr>{$nl}"; echo "\t<tr>{$nl}";
foreach($field as $td) { foreach($field as $td) {
$cell = ($escape) ? \bs_tts\safer_io::h($td) : $td; $cell = ($escape) ? \CodeHydrater\bootstrap\safer_io::h($td) : $td;
echo "\t\t<td>{$cell}</td>{$nl}"; echo "\t\t<td>{$cell}</td>{$nl}";
} }
echo "\t</tr>{$nl}"; echo "\t</tr>{$nl}";

@ -211,6 +211,12 @@ final class view {
echo $this->tempalte_engine_liquid->render($assigns, $filters, $registers); echo $this->tempalte_engine_liquid->render($assigns, $filters, $registers);
} else if ($view_file['file_type'] == '.twig') { } else if ($view_file['file_type'] == '.twig') {
$fns = $this->vars['twig_functions'] ?? [];
if (\CodeHydrater\common::get_count($fns)) {
foreach ($fns as $fn_label => $fn_name) {
$this->tempalte_engine_twig->addFunction(new \Twig\TwigFunction($fn_label, $fn_name));
}
}
$twig_data = $this->vars['twig_data'] ?? []; $twig_data = $this->vars['twig_data'] ?? [];
echo $this->tempalte_engine_twig->render($view_file['file'], $twig_data); echo $this->tempalte_engine_twig->render($view_file['file'], $twig_data);
} else { } else {

Loading…
Cancel
Save