20240814#2
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
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",
|
||||
]);
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
# Index
|
||||
- key: "/"
|
||||
routes:
|
||||
- action: "App\\Main\\Infrastructure\\Controllers\\IndexController"
|
||||
- action: "App\\Infrastructure\\Controllers\\IndexController"
|
||||
method: "index"
|
||||
params: ""
|
||||
|
||||
# Empty
|
||||
- key: "<@any>"
|
||||
routes:
|
||||
- action: "App\\Main\\Infrastructure\\Controllers\\IndexController"
|
||||
- action: "App\\nfrastructure\\Controllers\\IndexController"
|
||||
method: "emptyAction"
|
||||
params: ""
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
<?php
|
||||
|
||||
if(getenv("APP_MODE") == "PROD" && file_exists(dirname(__DIR__,3).'/var/routes/routes')){
|
||||
return unserialize(file_get_contents(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-main'));
|
||||
} else {
|
||||
$routesCollection = array_map(function ($routesFile){
|
||||
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));
|
||||
|
||||
if(getenv("APP_MODE") == "PROD") {
|
||||
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', serialize($routes));
|
||||
}
|
||||
file_put_contents(dirname(__DIR__, 3).'/var/routes/routes-main', serialize($routes));
|
||||
return $routes;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Main\Infrastructure\Controllers;
|
||||
namespace App\Infrastructure\Controllers;
|
||||
use Base\Infrastructure\Controllers\AbstractPageController;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
@@ -13,11 +13,12 @@ class IndexController extends AbstractPageController {
|
||||
try {
|
||||
//$this->addHeader("App-Mode", "Dev");
|
||||
$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);}
|
||||
return $this->render();
|
||||
|
||||
return $this->renderResponse("main", "@main/index.tpl", [
|
||||
"date" => (new \DateTime())->format('Y-m-d H:i:s'),
|
||||
"error" => $error ?? null
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user