mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-26 19:58:53 +02:00
Log when elements are created, edited or removed.
This commit is contained in:
parent
9f5a4ddf95
commit
eb071b1780
7 changed files with 213 additions and 0 deletions
|
@ -24,6 +24,8 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Entity\LogSystem;
|
||||
|
||||
use App\Entity\Base\AbstractDBElement;
|
||||
use App\Entity\Contracts\NamedElementInterface;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
|
@ -33,6 +35,32 @@ class ElementDeletedLogEntry extends AbstractLogEntry
|
|||
{
|
||||
protected $typeString = 'element_deleted';
|
||||
|
||||
public function __construct(AbstractDBElement $deleted_element)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->level = self::LEVEL_INFO;
|
||||
$this->setTargetElement($deleted_element);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @return $this
|
||||
*/
|
||||
public function setTargetElement(?AbstractDBElement $element): AbstractLogEntry
|
||||
{
|
||||
parent::setTargetElement($element);
|
||||
if ($element instanceof NamedElementInterface) {
|
||||
$this->setOldName($element->getName());
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setOldName(string $old_name): self
|
||||
{
|
||||
$this->extra['n'] = $old_name;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getOldName(): string
|
||||
{
|
||||
return $this->extra['n'];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue