feat: error-codes in flash messages to reference log entries
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Twig;
|
||||
|
||||
use App\Service\ErrorCodeService;
|
||||
use Twig\Extension\AbstractExtension;
|
||||
use Twig\TwigFunction;
|
||||
|
||||
class ErrorCodeExtension extends AbstractExtension
|
||||
{
|
||||
public function __construct(
|
||||
private readonly ErrorCodeService $errorCodeService,
|
||||
) {
|
||||
}
|
||||
|
||||
public function getFunctions(): array
|
||||
{
|
||||
return [
|
||||
new TwigFunction('error_code', [$this, 'getErrorCode']),
|
||||
new TwigFunction('has_error_code', [$this, 'hasErrorCode']),
|
||||
];
|
||||
}
|
||||
|
||||
public function getErrorCode(): ?string
|
||||
{
|
||||
return $this->errorCodeService->getErrorCode();
|
||||
}
|
||||
|
||||
public function hasErrorCode(): bool
|
||||
{
|
||||
return $this->errorCodeService->hasError();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user