Current path: home/webdevt/cryptoimpot.fr/module/Application/src/Mapper/
?? Go up: /home/webdevt/cryptoimpot.fr/module/Application/src
<?php
namespace Application\Mapper;
use Doctrine\ORM\EntityManager;
use TheSeer\Tokenizer\Exception;
use Laminas\Hydrator\HydratorInterface;
use Laminas\Paginator\Adapter\ArrayAdapter;
use Laminas\Paginator\Paginator;
class ImportMapper {
/**
* @var EntityManager
*/
protected $em;
protected $entityClass;
protected $orderAuthorized;
protected $orderByAuthorized;
public function __construct(EntityManager $em) {
$this->em = $em;
$this->entityClass = 'Application\Entity\Import';
$this->orderByAuthorized = array(
'id',
'name',
);
$this->orderAuthorized = array(
'ASC',
'DESC'
);
}
// public function findByEmail($email)
// {
// $er = $this->em->getRepository($this->entityClass);
// return $er->findOneBy(array('email' => $email));
// }
public function findByUser($user) {
$er = $this->em->getRepository($this->entityClass);
return $er->findBy(array('user' => $user));
}
public function findByName($name) {
$er = $this->em->getRepository($this->entityClass);
return $er->findBy(array('name' => $name));
}
public function findByExchangeAndUser($exchange, $user) {
$er = $this->em->getRepository($this->entityClass);
return $er->findBy(array('exchange' => $exchange, 'user' => $user));
}
public function findById($id) {
$er = $this->em->getRepository($this->entityClass);
return $er->findOneBy(array('id' => $id));
}
public function insert($entity, $tableName = null, HydratorInterface $hydrator = null) {
return $this->persist($entity);
}
public function update($entity, $where = null, $tableName = null, HydratorInterface $hydrator = null) {
return $this->persist($entity);
}
public function delete($entity, $where = null, $tableName = null, HydratorInterface $hydrator = null) {
try {
$this->em->remove($entity);
$this->em->flush();
return true;
} catch (Exception $e) {
return false;
}
}
protected function persist($entity) {
$this->em->persist($entity);
$this->em->flush();
return $entity;
}
}