2016-07-20 20:00:23 +03:00
|
|
|
<?php
|
2017-10-12 11:13:20 +03:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2016-07-20 20:00:23 +03:00
|
|
|
namespace Shlinkio\Shlink\Core\Service;
|
|
|
|
|
|
|
|
use Doctrine\ORM\EntityManagerInterface;
|
|
|
|
use Shlinkio\Shlink\Core\Entity\Visit;
|
|
|
|
use Shlinkio\Shlink\Core\Repository\VisitRepository;
|
|
|
|
|
|
|
|
class VisitService implements VisitServiceInterface
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var EntityManagerInterface
|
|
|
|
*/
|
|
|
|
private $em;
|
|
|
|
|
|
|
|
public function __construct(EntityManagerInterface $em)
|
|
|
|
{
|
|
|
|
$this->em = $em;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return Visit[]
|
|
|
|
*/
|
|
|
|
public function getUnlocatedVisits()
|
|
|
|
{
|
|
|
|
/** @var VisitRepository $repo */
|
|
|
|
$repo = $this->em->getRepository(Visit::class);
|
|
|
|
return $repo->findUnlocatedVisits();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param Visit $visit
|
|
|
|
*/
|
|
|
|
public function saveVisit(Visit $visit)
|
|
|
|
{
|
|
|
|
$this->em->persist($visit);
|
|
|
|
$this->em->flush();
|
|
|
|
}
|
|
|
|
}
|