Allow to add a comment when editing/creating/deleting an element.

This commit is contained in:
Jan Böhmer 2020-02-23 00:44:52 +01:00
parent c14d6d91ff
commit b6f95ebe48
19 changed files with 421 additions and 47 deletions

View file

@ -43,12 +43,13 @@ declare(strict_types=1);
namespace App\Entity\LogSystem;
use App\Entity\Base\AbstractDBElement;
use App\Entity\Contracts\LogWithCommentInterface;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity()
*/
class ElementCreatedLogEntry extends AbstractLogEntry
class ElementCreatedLogEntry extends AbstractLogEntry implements LogWithCommentInterface
{
protected $typeString = 'element_created';
@ -78,4 +79,29 @@ class ElementCreatedLogEntry extends AbstractLogEntry
{
return null !== $this->getCreationInstockValue();
}
/**
* @inheritDoc
*/
public function hasComment(): bool
{
return isset($this->extra['m']);
}
/**
* @inheritDoc
*/
public function getComment(): ?string
{
return $this->extra['m'] ?? null;
}
/**
* @inheritDoc
*/
public function setComment(?string $new_comment): LogWithCommentInterface
{
$this->extra['m'] = $new_comment;
return $this;
}
}

View file

@ -43,6 +43,7 @@ declare(strict_types=1);
namespace App\Entity\LogSystem;
use App\Entity\Base\AbstractDBElement;
use App\Entity\Contracts\LogWithCommentInterface;
use App\Entity\Contracts\NamedElementInterface;
use App\Entity\Contracts\TimeTravelInterface;
use Doctrine\ORM\Mapping as ORM;
@ -50,7 +51,7 @@ use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity()
*/
class ElementDeletedLogEntry extends AbstractLogEntry implements TimeTravelInterface
class ElementDeletedLogEntry extends AbstractLogEntry implements TimeTravelInterface, LogWithCommentInterface
{
protected $typeString = 'element_deleted';
@ -111,4 +112,29 @@ class ElementDeletedLogEntry extends AbstractLogEntry implements TimeTravelInter
{
return $this->extra['d'] ?? [];
}
/**
* @inheritDoc
*/
public function hasComment(): bool
{
return isset($this->extra['m']);
}
/**
* @inheritDoc
*/
public function getComment(): ?string
{
return $this->extra['m'] ?? null;
}
/**
* @inheritDoc
*/
public function setComment(?string $new_comment): LogWithCommentInterface
{
$this->extra['m'] = $new_comment;
return $this;
}
}

View file

@ -43,13 +43,14 @@ declare(strict_types=1);
namespace App\Entity\LogSystem;
use App\Entity\Base\AbstractDBElement;
use App\Entity\Contracts\LogWithCommentInterface;
use App\Entity\Contracts\TimeTravelInterface;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity()
*/
class ElementEditedLogEntry extends AbstractLogEntry implements TimeTravelInterface
class ElementEditedLogEntry extends AbstractLogEntry implements TimeTravelInterface, LogWithCommentInterface
{
protected $typeString = 'element_edited';
@ -72,16 +73,6 @@ class ElementEditedLogEntry extends AbstractLogEntry implements TimeTravelInterf
return $this;
}
/**
* Returns the message associated with this edit change.
*
* @return string
*/
public function getMessage(): string
{
return $this->extra['m'] ?? '';
}
/**
* @inheritDoc
*/
@ -97,4 +88,29 @@ class ElementEditedLogEntry extends AbstractLogEntry implements TimeTravelInterf
{
return $this->extra['d'] ?? [];
}
/**
* @inheritDoc
*/
public function hasComment(): bool
{
return isset($this->extra['m']);
}
/**
* @inheritDoc
*/
public function getComment(): ?string
{
return $this->extra['m'] ?? null;
}
/**
* @inheritDoc
*/
public function setComment(?string $new_comment): LogWithCommentInterface
{
$this->extra['m'] = $new_comment;
return $this;
}
}