mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-08-16 07:47:57 +02:00
Made the magic strings of EventCommentHelper into an array
This commit is contained in:
parent
a0a7ca3c9c
commit
6df7bc5f2a
6 changed files with 62 additions and 33 deletions
|
@ -22,6 +22,7 @@ declare(strict_types=1);
|
|||
*/
|
||||
namespace App\Twig;
|
||||
|
||||
use App\Services\LogSystem\EventCommentType;
|
||||
use Twig\TwigFunction;
|
||||
use App\Services\LogSystem\EventCommentNeededHelper;
|
||||
use Twig\Extension\AbstractExtension;
|
||||
|
@ -35,9 +36,16 @@ final class MiscExtension extends AbstractExtension
|
|||
public function getFunctions(): array
|
||||
{
|
||||
return [
|
||||
new TwigFunction('event_comment_needed',
|
||||
fn(string $operation_type) => $this->eventCommentNeededHelper->isCommentNeeded($operation_type)
|
||||
),
|
||||
new TwigFunction('event_comment_needed', $this->evenCommentNeeded(...)),
|
||||
];
|
||||
}
|
||||
|
||||
private function evenCommentNeeded(string|EventCommentType $operation_type): bool
|
||||
{
|
||||
if (is_string($operation_type)) {
|
||||
$operation_type = EventCommentType::from($operation_type);
|
||||
}
|
||||
|
||||
return $this->eventCommentNeededHelper->isCommentNeeded($operation_type);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue