1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Loevgaard\DandomainAltapayBundle\Entity; |
4
|
|
|
|
5
|
|
|
use Doctrine\Common\Persistence\ManagerRegistry; |
6
|
|
|
use Doctrine\ORM\QueryBuilder; |
7
|
|
|
use Knp\Component\Pager\Pagination\PaginationInterface; |
8
|
|
|
use Knp\Component\Pager\PaginatorInterface; |
9
|
|
|
use Lexik\Bundle\FormFilterBundle\Filter\FilterBuilderUpdaterInterface; |
10
|
|
|
use Symfony\Component\Form\FormInterface; |
11
|
|
|
use Symfony\Component\HttpFoundation\Request; |
12
|
|
|
|
13
|
|
|
class PaymentRepository extends EntityRepository |
14
|
|
|
{ |
15
|
|
|
/** |
16
|
|
|
* @var FilterBuilderUpdaterInterface |
17
|
|
|
*/ |
18
|
|
|
protected $filterBuilderUpdater; |
19
|
|
|
|
20
|
|
|
public function __construct(ManagerRegistry $managerRegistry, PaginatorInterface $paginator, string $class, FilterBuilderUpdaterInterface $filterBuilderUpdater) |
21
|
|
|
{ |
22
|
|
|
$this->filterBuilderUpdater = $filterBuilderUpdater; |
23
|
|
|
|
24
|
|
|
parent::__construct($managerRegistry, $paginator, $class); |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @param $id |
29
|
|
|
* |
30
|
|
|
* @return null|Payment |
31
|
|
|
*/ |
32
|
|
|
public function findByOrderIdOrAltapayId($id): ?Payment |
33
|
|
|
{ |
34
|
|
|
/** @var Payment $payment */ |
35
|
|
|
$payment = $this->findOneBy([ |
36
|
|
|
'orderId' => $id, |
37
|
|
|
]); |
38
|
|
|
|
39
|
|
|
if (!$payment) { |
40
|
|
|
/** @var Payment $payment */ |
41
|
|
|
$payment = $this->findOneBy([ |
|
|
|
|
42
|
|
|
'altapayId' => $id, |
43
|
|
|
]); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
return $payment; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @param array $ids |
51
|
|
|
* @return Payment[] |
52
|
|
|
*/ |
53
|
|
|
public function findByIds(array $ids) : array |
54
|
|
|
{ |
55
|
|
|
$qb = $this->getQueryBuilder('p'); |
56
|
|
|
$qb->where($qb->expr()->in('p.id', ':ids')); |
57
|
|
|
$qb->setParameter('ids', $ids); |
58
|
|
|
|
59
|
|
|
return $qb->getQuery()->getResult(); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
public function findAllWithPagingAndFilter($page = 1, $itemsPerPage = 100, array $orderBy = [], FormInterface $filterForm, Request $request, QueryBuilder $qb = null): PaginationInterface |
63
|
|
|
{ |
64
|
|
|
if (!$qb) { |
65
|
|
|
$qb = $this->getQueryBuilder('e'); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
if ($request->query->has($filterForm->getName())) { |
69
|
|
|
// manually bind values from the request |
70
|
|
|
$filterForm->submit($request->query->get($filterForm->getName())); |
71
|
|
|
|
72
|
|
|
// build the query from the given form object |
73
|
|
|
$this->filterBuilderUpdater->addFilterConditions($filterForm, $qb); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
foreach ($orderBy as $field => $direction) { |
77
|
|
|
$qb->addOrderBy($field, $direction); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
$objs = $this->paginator->paginate( |
81
|
|
|
$qb, |
82
|
|
|
$page, |
83
|
|
|
$itemsPerPage |
84
|
|
|
); |
85
|
|
|
|
86
|
|
|
return $objs; |
87
|
|
|
} |
88
|
|
|
} |
89
|
|
|
|
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()
can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.