delboy1978uk /
user
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Del\Repository; |
||
| 4 | |||
| 5 | use Del\Entity\EmailLink as EmailLinkEntity; |
||
| 6 | use Doctrine\ORM\EntityRepository; |
||
| 7 | |||
| 8 | class EmailLink extends EntityRepository |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * @param EmailLinkEntity $link |
||
| 12 | * @return EmailLinkEntity |
||
| 13 | * @throws \Doctrine\ORM\OptimisticLockException |
||
| 14 | */ |
||
| 15 | public function save(EmailLinkEntity $link) |
||
| 16 | { |
||
| 17 | $this->_em->persist($link); |
||
| 18 | $this->_em->flush(); |
||
| 19 | return $link; |
||
| 20 | } |
||
| 21 | |||
| 22 | /** |
||
| 23 | * @param EmailLinkEntity $link |
||
| 24 | * @throws \Doctrine\ORM\OptimisticLockException |
||
| 25 | */ |
||
| 26 | public function delete(EmailLinkEntity $link) |
||
| 27 | { |
||
| 28 | $this->_em->remove($link); |
||
| 29 | $this->_em->flush(); |
||
| 30 | } |
||
| 31 | |||
| 32 | /** |
||
| 33 | * @param string $token |
||
| 34 | * @return EmailLinkEntity|null |
||
| 35 | */ |
||
| 36 | public function findByToken($token) |
||
| 37 | { |
||
| 38 | $qb = $this->createQueryBuilder('el'); |
||
| 39 | |||
| 40 | $qb->where('el.token = :token'); |
||
| 41 | $qb->setParameter('token', $token); |
||
| 42 | |||
| 43 | $query = $qb->getQuery(); |
||
| 44 | $result = $query->getResult(); |
||
| 45 | return count($result) ? $result[0] : null; |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 46 | } |
||
| 47 | } |
||
| 48 |