<?php
/**
 * For the full copyright and license information, please view the
 * docs/licenses/LICENSE.txt file that was distributed with this source code.
 */

declare(strict_types=1);

namespace PrestaShopBundle\Service\Database;

use Doctrine\ORM\EntityManager;
use PrestaShop\PrestaShop\Core\Repository\TransactionManagerInterface;

class TransactionManager implements TransactionManagerInterface
{
    /**
     * @var EntityManager
     */
    private $entityManager;

    /**
     * @param EntityManager $entityManager
     */
    public function __construct(EntityManager $entityManager)
    {
        $this->entityManager = $entityManager;
    }

    /**
     * {@inheritdoc}
     */
    public function rollback(): void
    {
        $this->entityManager->rollback();
    }

    /**
     * {@inheritdoc}
     */
    public function commit(): void
    {
        $this->entityManager->commit();
    }

    /**
     * {@inheritdoc}
     */
    public function beginTransaction(): void
    {
        $this->entityManager->beginTransaction();
    }
}
