20240814#2

This commit is contained in:
User
2024-08-14 21:27:27 +03:00
parent 72d2445bb2
commit 99f78f7362
11 changed files with 14 additions and 15 deletions

View File

@@ -1,4 +1,4 @@
<?php <?php
return (new \Rmphp\Content\Content('/application/src/Infrastructure/templates/base.tpl'))->setSubtemplatePath('/application/src/Infrastructure/templates/')->setSubtemplatePathAlias([ return (new \Rmphp\Content\Content('/application/src/Infrastructure/templates/base.tpl'))->setSubtemplatePath('/application/src/Infrastructure/templates/')->setSubtemplatePathAlias([
"main" => "/src/Main/Infrastructure/templates", "main" => "/src/Infrastructure/templates",
]); ]);

View File

@@ -1,13 +1,13 @@
# Index # Index
- key: "/" - key: "/"
routes: routes:
- action: "App\\Main\\Infrastructure\\Controllers\\IndexController" - action: "App\\Infrastructure\\Controllers\\IndexController"
method: "index" method: "index"
params: "" params: ""
# Empty # Empty
- key: "<@any>" - key: "<@any>"
routes: routes:
- action: "App\\Main\\Infrastructure\\Controllers\\IndexController" - action: "App\\nfrastructure\\Controllers\\IndexController"
method: "emptyAction" method: "emptyAction"
params: "" params: ""

View File

@@ -1,17 +1,15 @@
<?php <?php
if(getenv("APP_MODE") == "PROD" && file_exists(dirname(__DIR__,3).'/var/routes/routes')){ if(getenv("APP_MODE") == "PROD" && file_exists(dirname(__DIR__,3).'/var/routes/routes-main')){
return unserialize(file_get_contents(dirname(__DIR__,3).'/var/routes/routes')); return unserialize(file_get_contents(dirname(__DIR__,3).'/var/routes/routes-main'));
} else { } else {
$routesCollection = array_map(function ($routesFile){ $routesCollection = array_map(function ($routesFile){
return file_get_contents($routesFile).PHP_EOL; return file_get_contents($routesFile).PHP_EOL;
}, array_merge(glob(__DIR__."/*/{*.yaml}", GLOB_BRACE), glob(__DIR__."/{*.yaml}", GLOB_BRACE))); }, glob(__DIR__."/{*.yaml}", GLOB_BRACE));
$routes = yaml_parse(implode($routesCollection)); $routes = yaml_parse(implode($routesCollection));
if(getenv("APP_MODE") == "PROD") { if (!is_dir(dirname(__DIR__, 3).'/var/routes')) mkdir(dirname(__DIR__, 3).'/var/routes', 0777, true);
if (!is_dir(dirname(__DIR__, 3).'/var/routes')) mkdir(dirname(__DIR__, 3).'/var/routes', 0777, true); file_put_contents(dirname(__DIR__, 3).'/var/routes/routes-main', serialize($routes));
file_put_contents(dirname(__DIR__, 3).'/var/routes/routes', serialize($routes));
}
return $routes; return $routes;
} }

View File

@@ -1,6 +1,6 @@
<?php <?php
namespace App\Main\Infrastructure\Controllers; namespace App\Infrastructure\Controllers;
use Base\Infrastructure\Controllers\AbstractPageController; use Base\Infrastructure\Controllers\AbstractPageController;
use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ResponseInterface;
@@ -13,11 +13,12 @@ class IndexController extends AbstractPageController {
try { try {
//$this->addHeader("App-Mode", "Dev"); //$this->addHeader("App-Mode", "Dev");
$this->template()->setValue("title", "Главная"); $this->template()->setValue("title", "Главная");
$this->template()->setSubtemplate("main", "@main/index.tpl", [
"date" => (new \DateTime())->format('Y-m-d H:i:s')
]);
} }
catch(\Throwable $e){$error = $this->checkError($e);} catch(\Throwable $e){$error = $this->checkError($e);}
return $this->render();
return $this->renderResponse("main", "@main/index.tpl", [
"date" => (new \DateTime())->format('Y-m-d H:i:s'),
"error" => $error ?? null
]);
} }
} }