Dont make new version if content didnt change
This commit is contained in:
@ -15,14 +15,17 @@ readonly class SnipContentService
|
||||
|
||||
public function update(string $snipContents): void
|
||||
{
|
||||
if ($this->snip->getActiveVersion()?->getText() === $snipContents) {
|
||||
return;
|
||||
}
|
||||
// Create new snipContent entity with previous one as parent
|
||||
$content = new SnipContent();
|
||||
$content
|
||||
->setText($snipContents)
|
||||
->setSnip($this->snip)
|
||||
;
|
||||
if ($this->snip->getSnipContents()->count() > 0) {
|
||||
$content->setParent($this->snip->getSnipContents()->last());
|
||||
if ($this->snip->getActiveVersion() !== null) {
|
||||
$content->setParent($this->snip->getActiveVersion());
|
||||
}
|
||||
|
||||
$this->em->persist($content);
|
||||
|
Reference in New Issue
Block a user