Skip to content

Instantly share code, notes, and snippets.

@maciejmiara
Created May 7, 2019 06:13
Show Gist options
  • Save maciejmiara/b7251c725eb5e67c2379593bdfbc0413 to your computer and use it in GitHub Desktop.
Save maciejmiara/b7251c725eb5e67c2379593bdfbc0413 to your computer and use it in GitHub Desktop.
<?php
declare(strict_types = 1);
namespace Infrastructure\Framework\Repository;
use Doctrine\ORM\EntityManagerInterface;
use Domain\Model\RunParticipation;
use Infrastructure\Doctrine\Transformer\RunParticipationTransformer;
use Infrastructure\Framework\Entity\RunParticipation as RunParticipationEntity;
class RunParticipationRepository implements \Domain\Repository\RunParticipationRepository
{
private $entityManager;
private $entityRepository;
private $runParticipationTransformer;
public function __construct(EntityManagerInterface $entityManager, RunParticipationTransformer $runParticipationTransformer)
{
$this->entityManager = $entityManager;
$this->entityRepository = $entityManager->getRepository(RunParticipationEntity::class);
$this->runParticipationTransformer = $runParticipationTransformer;
}
/**
* {@inheritdoc}
*/
public function save(RunParticipation $runParticipation): void
{
$dbRunParticipation = $this->runParticipationTransformer->domainToEntity($runParticipation);
$this->entityManager->persist($dbRunParticipation);
$this->entityManager->flush();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment