Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions src/Doctrine/EntityClassGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@

use ApiPlatform\Metadata\ApiResource;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\ORM\Exception\ORMException;
use Doctrine\ORM\Mapping;
use Doctrine\ORM\OptimisticLockException;
use Doctrine\Persistence\ManagerRegistry;
use Symfony\Bundle\MakerBundle\Generator;
use Symfony\Bundle\MakerBundle\Str;
Expand Down Expand Up @@ -108,8 +106,6 @@ public function generateRepositoryClass(string $repositoryClass, string $entityC
$entityClass,
ManagerRegistry::class,
ServiceEntityRepository::class,
OptimisticLockException::class,
ORMException::class,
]);

if ($withPasswordUpgrade) {
Expand Down
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);
$this->getEntityManager()->persist($entity);

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

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

if ($flush) {
$this->_em->flush();
$this->getEntityManager()->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
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
namespace Symfony\Bundle\MakerBundle\Tests\tmp\current_project_xml\src\Repository;

use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\ORM\Exception\ORMException;
use Doctrine\ORM\OptimisticLockException;
use Doctrine\Persistence\ManagerRegistry;
use Symfony\Bundle\MakerBundle\Tests\tmp\current_project_xml\src\Entity\UserXml;

Expand All @@ -23,27 +21,21 @@ public function __construct(ManagerRegistry $registry)
parent::__construct($registry, UserXml::class);
}

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

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

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
namespace Symfony\Bundle\MakerBundle\Tests\tmp\current_project_xml\src\Repository;

use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\ORM\Exception\ORMException;
use Doctrine\ORM\OptimisticLockException;
use Doctrine\Persistence\ManagerRegistry;
use Symfony\Bundle\MakerBundle\Tests\tmp\current_project_xml\src\Entity\XOther;

Expand All @@ -23,27 +21,21 @@ public function __construct(ManagerRegistry $registry)
parent::__construct($registry, XOther::class);
}

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

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

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

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

Expand Down