Skip to content
Snippets Groups Projects
Commit fc490bed authored by Pierre Fleutot's avatar Pierre Fleutot
Browse files

Fix copy entry : on ne clone pas, on crée une nouvelle instance

parent 8239fd16
No related branches found
No related tags found
No related merge requests found
......@@ -285,14 +285,7 @@ class ApiEntryController extends AppBaseController
break;
}
} else {
$newEntry = clone($entry);
$newEntry->setLexicon($lexicon);
$newEntry->setCreatedAt(new \DateTimeImmutable());
$newEntry->setUpdatedAt(null);
$this->doctrine->getManager()->persist($newEntry);
$this->addLexiconLog($newEntry, Log::CATEGORY_ADD_ENTRY);
$newEntry = $this->copyEntryInLexicon($entry, $lexicon);
$this->doctrine->getManager()->flush();
$added[] = $newEntry->getId();
}
......
......@@ -368,6 +368,21 @@ class AppBaseController extends AbstractController
return $entry;
}
public function copyEntryInLexicon(Entry $entry, Lexicon $lexicon)
{
$newEntry = new Entry();
$newEntry->setCreatedBy($this->getUser());
$this->doctrine->getManager()->persist($entry);
$newEntry->setHeadword($entry->getHeadword());
$newEntry->setLanguage($entry->getLanguage());
$newEntry->setLexicon($lexicon);
$newEntry->setAttributes($entry->getAttributes());
$this->addLexiconLog($entry, Log::CATEGORY_COPY_ENTRY);
return $entry;
}
/**
* - On ajoute les commentaires de l'entrée source à la suite de ceux de l'entrée cible
* - On ajoute les items de l'entrée source à la suite de ceux de l'entrée cible
......
......@@ -20,9 +20,11 @@ class Log
const CATEGORY_UPDATE_COMMENT = 'update_comment';
const CATEGORY_UPDATE_DISCUSSION = 'update_discussion';
const CATEGORY_UPDATE_ENTRY = 'update_entry';
const CATEGORY_ADD_ENTRY = 'add_entry';
const CATEGORY_DELETE_ENTRY = 'delete_entry';
const CATEGORY_UPDATE_ENTRY = 'update_entry';
const CATEGORY_ADD_ENTRY = 'add_entry';
const CATEGORY_COPY_ENTRY = 'copy_entry';
const CATEGORY_COPY_ENTRY_OF_THE_DAY = 'copy_entry_of_the_day';
const CATEGORY_DELETE_ENTRY = 'delete_entry';
const CATEGORY_DELETE_LABEL = 'delete_label';
const CATEGORY_RENAME_LABEL = 'rename_label';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment