for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace RemiSan\TransactionManager\Doctrine;
use Doctrine\ORM\EntityManagerInterface;
use RemiSan\TransactionManager\Exception\BeginException;
use RemiSan\TransactionManager\Exception\CommitException;
use RemiSan\TransactionManager\Exception\RollbackException;
use RemiSan\TransactionManager\Transactional;
class DoctrineEntityManager implements Transactional
{
/**
* @var EntityManagerInterface
*/
private $entityManager;
* Constructor.
*
* @param EntityManagerInterface $entityManager
public function __construct(EntityManagerInterface $entityManager)
$this->entityManager = $entityManager;
}
* {@inheritdoc}
public function beginTransaction()
try {
$this->entityManager->beginTransaction();
} catch (\Exception $e) {
throw new BeginException('Cannot begin Doctrine ORM transaction', $e->getCode(), $e);
public function commit()
$this->entityManager->commit();
throw new CommitException('Cannot commit Doctrine ORM transaction', $e->getCode(), $e);
public function rollback()
$this->entityManager->rollback();
throw new RollbackException('Cannot rollback Doctrine ORM transaction', $e->getCode(), $e);