mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-05 07:54:35 +02:00
Allow to show collection elements that were deleted before by timetravel
This commit is contained in:
parent
b5bc096972
commit
f604022e49
9 changed files with 386 additions and 78 deletions
|
@ -43,6 +43,7 @@ declare(strict_types=1);
|
|||
namespace App\Services\LogSystem;
|
||||
|
||||
use App\Entity\LogSystem\AbstractLogEntry;
|
||||
use App\Entity\LogSystem\CollectionElementDeleted;
|
||||
use App\Entity\LogSystem\DatabaseUpdatedLogEntry;
|
||||
use App\Entity\LogSystem\ElementCreatedLogEntry;
|
||||
use App\Entity\LogSystem\ElementDeletedLogEntry;
|
||||
|
@ -52,6 +53,8 @@ use App\Entity\LogSystem\InstockChangedLogEntry;
|
|||
use App\Entity\LogSystem\UserLoginLogEntry;
|
||||
use App\Entity\LogSystem\UserLogoutLogEntry;
|
||||
use App\Entity\LogSystem\UserNotAllowedLogEntry;
|
||||
use App\Services\ElementTypeNameGenerator;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
/**
|
||||
|
@ -60,10 +63,12 @@ use Symfony\Contracts\Translation\TranslatorInterface;
|
|||
class LogEntryExtraFormatter
|
||||
{
|
||||
protected $translator;
|
||||
protected $elementTypeNameGenerator;
|
||||
|
||||
public function __construct(TranslatorInterface $translator)
|
||||
public function __construct(TranslatorInterface $translator, ElementTypeNameGenerator $elementTypeNameGenerator)
|
||||
{
|
||||
$this->translator = $translator;
|
||||
$this->elementTypeNameGenerator = $elementTypeNameGenerator;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -174,6 +179,15 @@ class LogEntryExtraFormatter
|
|||
);
|
||||
}
|
||||
|
||||
if ($context instanceof CollectionElementDeleted) {
|
||||
return sprintf('<i>%s</i>: %s: %s (%s)',
|
||||
$this->translator->trans('log.collection_deleted.deleted'),
|
||||
$this->elementTypeNameGenerator->getLocalizedTypeLabel($context->getDeletedElementClass()),
|
||||
$context->getOldName() ?? $context->getDeletedElementID(),
|
||||
$context->getCollectionName()
|
||||
);
|
||||
}
|
||||
|
||||
if ($context instanceof UserNotAllowedLogEntry) {
|
||||
return htmlspecialchars($context->getMessage());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue