1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace ControleOnline\Service; |
4
|
|
|
|
5
|
|
|
use ControleOnline\Entity\Order; |
6
|
|
|
use ControleOnline\Entity\People; |
|
|
|
|
7
|
|
|
use ControleOnline\Entity\Status; |
8
|
|
|
use Doctrine\ORM\EntityManagerInterface; |
|
|
|
|
9
|
|
|
use Symfony\Component\Security\Core\Security; |
|
|
|
|
10
|
|
|
use Doctrine\ORM\QueryBuilder; |
|
|
|
|
11
|
|
|
use Symfony\Component\HttpFoundation\RequestStack; |
|
|
|
|
12
|
|
|
|
13
|
|
|
class OrderService |
14
|
|
|
{ |
15
|
|
|
private $request; |
16
|
|
|
|
17
|
|
|
public function __construct( |
18
|
|
|
private EntityManagerInterface $manager, |
19
|
|
|
private Security $security, |
20
|
|
|
private PeopleService $PeopleService, |
|
|
|
|
21
|
|
|
RequestStack $requestStack |
22
|
|
|
|
23
|
|
|
) { |
24
|
|
|
$this->request = $requestStack->getCurrentRequest(); |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
|
28
|
|
|
public function createOrder(People $receiver, People $payer) |
29
|
|
|
{ |
30
|
|
|
|
31
|
|
|
$order = new Order(); |
32
|
|
|
$order->setProvider($receiver); |
33
|
|
|
$order->setClient($payer); |
34
|
|
|
$order->setPayer($payer); |
35
|
|
|
$order->setOrderType('sales'); |
36
|
|
|
$order->setOrderStatus($this->manager->getRepository(Status::class)->findOneBy([ |
|
|
|
|
37
|
|
|
'status' => 'open', |
38
|
|
|
'context' => 'order', |
39
|
|
|
'people' => $receiver |
40
|
|
|
])); |
41
|
|
|
$order->setApp('Asaas'); |
42
|
|
|
$this->manager->persist($order); |
43
|
|
|
$this->manager->flush(); |
44
|
|
|
return $order; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
public function secutiryFilter(QueryBuilder $queryBuilder, $resourceClass = null, $applyTo = null, $rootAlias = null): void |
|
|
|
|
48
|
|
|
{ |
49
|
|
|
$companies = $this->PeopleService->getMyCompanies(); |
50
|
|
|
|
51
|
|
|
if ($invoice = $this->request->query->get('invoiceId', null)) { |
52
|
|
|
$queryBuilder->join(sprintf('%s.invoice', $rootAlias), 'OrderInvoice'); |
53
|
|
|
$queryBuilder->andWhere(sprintf('OrderInvoice.invoice IN(:invoice)', $rootAlias, $rootAlias)); |
54
|
|
|
$queryBuilder->setParameter('invoice', $invoice); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
$queryBuilder->andWhere(sprintf('%s.client IN(:companies) OR %s.provider IN(:companies)', $rootAlias, $rootAlias)); |
58
|
|
|
$queryBuilder->setParameter('companies', $companies); |
59
|
|
|
|
60
|
|
|
if ($provider = $this->request->query->get('provider', null)) { |
61
|
|
|
$queryBuilder->andWhere(sprintf('%s.provider IN(:provider)', $rootAlias)); |
62
|
|
|
$queryBuilder->setParameter('provider', preg_replace("/[^0-9]/", "", $provider)); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
if ($client = $this->request->query->get('client', null)) { |
66
|
|
|
$queryBuilder->andWhere(sprintf('%s.client IN(:client)', $rootAlias)); |
67
|
|
|
$queryBuilder->setParameter('client', preg_replace("/[^0-9]/", "", $client)); |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
} |
71
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths