This commit is contained in:
elvira committed 2026-10-26 16:06:55 +02:00
1 parent 50ec0eebf2
commit 1e4da2c8cc
73 files changed
+763 -43

No files matched your search

+3 -32
View File
@@ -3,26 +3,12 @@
namespace App\Http\Controllers;
use App\Models\StoicPage;
use Modules\Core\Store\Services\StoreDetailsService;
use App\Support\StorePlaceholders;
class LegalPageController extends Controller
{
/**
* {placeholder} => StoreDetails column, usable in the Stoic legal page
* markdown.
*/
private const PLACEHOLDERS = [
'{store_name}' => 'name',
'{store_address}' => 'address',
'{store_phone}' => 'phone',
'{store_contact_email}' => 'contact_email',
'{store_legal_name}' => 'legal_name',
'{store_tax_identifier}' => 'tax_identifier',
'{store_registration_number}' => 'registration_number',
];
public function __construct(
private readonly StoreDetailsService $storeDetails,
private readonly StorePlaceholders $placeholders,
) {}
public function terms(string $locale)
@@ -55,22 +41,7 @@ private function show(string $slug)
return view('legal', [
'page' => $page,
'content' => $this->fillPlaceholders($page->content ?? ''),
'content' => $this->placeholders->fill($page->content ?? ''),
]);
}
/**
* Swapped in before the markdown is rendered, so values are escaped: the
* rendered markdown is printed unescaped. An empty field renders as
* nothing rather than leaving the raw placeholder on the page.
*/
private function fillPlaceholders(string $content): string
{
$details = $this->storeDetails->current();
return strtr($content, array_map(
fn (string $column) => e((string) ($details->translate($column) ?? '')),
self::PLACEHOLDERS,
));
}
}