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\Creator; |
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
|
|
|
|
19
|
|
|
final class ChangePositionPaymentMethodCreator implements ChangePositionPaymentMethodCreatorInterface |
20
|
|
|
{ |
21
|
|
|
/** @var RepositoryInterface */ |
22
|
|
|
private $mollieGatewayRepository; |
23
|
|
|
|
24
|
|
|
/** @var ObjectManager */ |
25
|
|
|
private $mollieGatewayObjectManager; |
26
|
|
|
|
27
|
|
|
public function __construct( |
28
|
|
|
RepositoryInterface $mollieGatewayRepository, |
29
|
|
|
ObjectManager $mollieGatewayObjectManager |
30
|
|
|
) { |
31
|
|
|
$this->mollieGatewayRepository = $mollieGatewayRepository; |
32
|
|
|
$this->mollieGatewayObjectManager = $mollieGatewayObjectManager; |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
public function createFromRequest(Request $request): void |
36
|
|
|
{ |
37
|
|
|
$positions = $this->emptyPositionFilter($request->get('data', [])); |
38
|
|
|
|
39
|
|
|
foreach ($positions as $position) { |
40
|
|
|
$method = $this->mollieGatewayRepository->findOneBy(['methodId' => $position['name']]); |
41
|
|
|
if ($method instanceof MollieGatewayConfigInterface && isset($position['id'])) { |
42
|
|
|
$method->setPosition((int) $position['id']); |
43
|
|
|
|
44
|
|
|
$this->mollieGatewayObjectManager->persist($method); |
45
|
|
|
} |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
$this->mollieGatewayObjectManager->flush(); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
private function emptyPositionFilter(array $positions): array |
52
|
|
|
{ |
53
|
|
|
return array_filter($positions, function (array $position): bool { |
54
|
|
|
return isset($position['id']) && $position['id'] !== ''; |
55
|
|
|
}); |
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
|
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