Skip to content

Commit

Permalink
[make:entity] _em will be private in ORM 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jrushlow committed May 9, 2022
1 parent 4b994df commit fa964bc
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions src/Resources/skeleton/doctrine/Repository.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,21 @@ public function __construct(ManagerRegistry $registry)
parent::__construct($registry, <?= $entity_class_name; ?>::class);
}

/**
* @throws ORMException
* @throws OptimisticLockException
*/
public function add(<?= $entity_class_name ?> $entity, bool $flush = false): void
{
$this->_em->persist($entity);
($em = $this->getEntityManager())->persist($entity);

if ($flush) {
$this->_em->flush();
$em->flush();
}
}

/**
* @throws ORMException
* @throws OptimisticLockException
*/
public function remove(<?= $entity_class_name ?> $entity, bool $flush = false): void
{
$this->_em->remove($entity);
($em = $this->getEntityManager())->remove($entity);

if ($flush) {
$this->_em->flush();
$em->flush();
}
}
<?php if ($include_example_comments): // When adding a new method without existing default comments, the blank line is automatically added.?>
Expand All @@ -56,8 +50,8 @@ public function upgradePassword(<?= sprintf('%s ', $password_upgrade_user_interf
}

$user->setPassword($newHashedPassword);
$this->_em->persist($user);
$this->_em->flush();

$this->add($user, true);
}

<?php endif ?>
Expand Down

0 comments on commit fa964bc

Please sign in to comment.