2024.12.01 18:26:02

This commit is contained in:
Christian Moser 2024-12-01 18:26:02 +01:00
parent 1025cf621a
commit 7da2ac7d2a
3 changed files with 24 additions and 13 deletions

View File

@ -5,28 +5,38 @@ namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Routing\Attribute\Route;
use \Symfony\Component\HttpKernel\KernelInterface;
abstract class WebrootController extends AbstractController abstract class WebrootController extends AbstractController
{ {
private ?string $project_dir = null;
public function __construct(KernelInterface $kernel)
{
$this->project_dir = $kernel->getProjectDir();
}
public function getHeaderTitleFiglet(): ?string public function getHeaderTitleFiglet(): ?string
{ {
$header_title_figlet_file = getenv("HEADER_TITLE_FIGLET"); $filename = getenv("HEADER_TITLE_FIGLET");
if ($header_title_figlet_file && strlen($header_title_figlet_file)) { if (!$filename || !strlen($filename) || !file_exists($filename)) {
$figlet_file = fopen($header_title_figlet_file,"r"); $filename = join(DIRECTORY_SEPARATOR,[dirname(dirname(__DIR__)),"templates","webroot.txt"]);
$header_figlet = fread($figlet_file, filesize($header_title_figlet_file));
fclose($figlet_file);
$title = "<div class=\"center\"><pre>"
. $header_figlet
. "</pre></div>";
return $title;
} }
return null; $figlet_file = fopen($filename,"r");
$header_figlet = fread($figlet_file, filesize($filename));
fclose($figlet_file);
$title = "<div class=\"center\"><pre>"
. $header_figlet
. "</pre></div>";
return $title;
return $title;
} }
protected function getControllerVariables(): array protected function getControllerVariables(): array
{ {
return [ return [
"header_title_figlet" => $this->getHeaderTitleFiglet(), "header_title" => $this->getHeaderTitleFiglet(),
]; ];
} }
} }

View File

@ -14,13 +14,14 @@
<body style="margin:0px;padding:0px;"> <body style="margin:0px;padding:0px;">
{% block body %} {% block body %}
<header class="header" style="color:lightgrey;padding:0px 5px 0px 5px;margin:0px;"> <header class="header" style="color:lightgrey;padding:0px 5px 0px 5px;margin:0px;">
{% block header %}{% if header_title|default(null) %}{{ header_title|raw }}{% else %} {% block header %}{% if header_title|default %}{{ header_title|raw }}{% else %}
<div class="center"><pre> <div class="center"><pre>
_ _ _ _
__ _____| |__ _ __ ___ ___ | |_ __ _____| |__ _ __ ___ ___ | |_
\ \ /\ / / _ \ '_ \| '__/ _ \ / _ \| __| \ \ /\ / / _ \ '_ \| '__/ _ \ / _ \| __|
\ V V / __/ |_) | | | (_) | (_) | |_ \ V V / __/ |_) | | | (_) | (_) | |_
\_/\_/ \___|_.__/|_| \___/ \___/ \__| \_/\_/ \___|_.__/|_| \___/ \___/ \__|
123
</pre></div>{% endif %} </pre></div>{% endif %}
{% endblock %} {% endblock %}
</header> </header>