Skip to content

Commit

Permalink
Merge pull request #62 from nestordedios/patch-1
Browse files Browse the repository at this point in the history
Override @GeneratedValue strategy when importing users
  • Loading branch information
bobdenotter authored Sep 16, 2022
2 parents 04f0d30 + 82283e9 commit f8fa06e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Import.php
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,12 @@ private function importUsers(array $data): void
$user->setBackendTheme($importUser->get('backendTheme', 'default'));
$user->setStatus($importUser->get('status', ($importUser->get('enabled') ? 'enabled' : 'disabled')));

// Override @GeneratedValue strategy
$metadata = $this->em->getClassMetadata(get_class($user));
$metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_NONE);
$metadata->setIdGenerator(new \Doctrine\ORM\Id\AssignedGenerator());
$user->setId($importUser->get('id'));

$this->em->persist($user);

$this->em->flush();
Expand Down

0 comments on commit f8fa06e

Please sign in to comment.