|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file has been created by developers from BitBag. |
|
5
|
|
|
* Feel free to contact us once you face any issues or want to start |
|
6
|
|
|
* You can find more information about us on https://bitbag.io and write us |
|
7
|
|
|
* an email on [email protected]. |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
declare(strict_types=1); |
|
11
|
|
|
|
|
12
|
|
|
namespace BitBag\SyliusMolliePlugin\Controller\Action\Admin; |
|
13
|
|
|
|
|
14
|
|
|
use BitBag\SyliusMolliePlugin\Entity\MollieGatewayConfigInterface; |
|
15
|
|
|
use Doctrine\Common\Persistence\ObjectManager; |
|
|
|
|
|
|
16
|
|
|
use Sylius\Component\Resource\Repository\RepositoryInterface; |
|
17
|
|
|
use Symfony\Component\HttpFoundation\Request; |
|
18
|
|
|
use Symfony\Component\HttpFoundation\Response; |
|
19
|
|
|
|
|
20
|
|
|
final class ChangePositionPaymentMethodAction |
|
21
|
|
|
{ |
|
22
|
|
|
/** @var RepositoryInterface */ |
|
23
|
|
|
private $mollieGatewayRepository; |
|
24
|
|
|
|
|
25
|
|
|
/** @var ObjectManager */ |
|
26
|
|
|
private $mollieGatewayObjectManager; |
|
27
|
|
|
|
|
28
|
|
|
public function __construct( |
|
29
|
|
|
RepositoryInterface $mollieGatewayRepository, |
|
30
|
|
|
ObjectManager $mollieGatewayObjectManager |
|
31
|
|
|
) { |
|
32
|
|
|
$this->mollieGatewayRepository = $mollieGatewayRepository; |
|
33
|
|
|
$this->mollieGatewayObjectManager = $mollieGatewayObjectManager; |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
public function __invoke(Request $request): Response |
|
37
|
|
|
{ |
|
38
|
|
|
$positions = $this->emptyPositionFilter($request->get('data', [])); |
|
39
|
|
|
|
|
40
|
|
|
foreach ($positions as $position) { |
|
41
|
|
|
$method = $this->mollieGatewayRepository->findOneBy(['methodId' => $position['name']]); |
|
42
|
|
|
if ($method instanceof MollieGatewayConfigInterface and isset($position['id'])) { |
|
43
|
|
|
$method->setPosition((int) $position['id']); |
|
44
|
|
|
|
|
45
|
|
|
$this->mollieGatewayObjectManager->persist($method); |
|
46
|
|
|
} |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
$this->mollieGatewayObjectManager->flush(); |
|
50
|
|
|
|
|
51
|
|
|
return new Response('OK'); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
private function emptyPositionFilter(array $positions): array |
|
55
|
|
|
{ |
|
56
|
|
|
return array_filter($positions, function (array $position): bool { |
|
57
|
|
|
return isset($position['id']) && $position['id'] !== ''; |
|
58
|
|
|
}); |
|
59
|
|
|
} |
|
60
|
|
|
} |
|
61
|
|
|
|
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