mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-22 09:53:35 +02:00
Allow to delete users while keeping log entries.
This commit is contained in:
parent
dae4e38256
commit
a0f934169c
4 changed files with 102 additions and 14 deletions
|
@ -143,10 +143,16 @@ abstract class AbstractLogEntry extends AbstractDBElement
|
|||
|
||||
/** @var User The user which has caused this log entry
|
||||
* @ORM\ManyToOne(targetEntity="App\Entity\UserSystem\User", fetch="EAGER")
|
||||
* @ORM\JoinColumn(name="id_user", nullable=false)
|
||||
* @ORM\JoinColumn(name="id_user", nullable=true, onDelete="SET NULL")
|
||||
*/
|
||||
protected ?User $user = null;
|
||||
|
||||
/**
|
||||
* @var string The username of the user which has caused this log entry (shown if the user is deleted)
|
||||
* @ORM\Column(type="string", nullable=false)
|
||||
*/
|
||||
protected string $username = '';
|
||||
|
||||
/** @var DateTime The datetime the event associated with this log entry has occured
|
||||
* @ORM\Column(type="datetime", name="datetime")
|
||||
*/
|
||||
|
@ -203,9 +209,22 @@ abstract class AbstractLogEntry extends AbstractDBElement
|
|||
{
|
||||
$this->user = $user;
|
||||
|
||||
//Save the username for later use
|
||||
$this->username = $user->getUsername();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retuns the username of the user that caused the event (useful if the user was deleted).
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getUsername(): string
|
||||
{
|
||||
return $this->username;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the timestamp when the event that caused this log entry happened.
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue