1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Copyright © 2016-present Spryker Systems GmbH. All rights reserved. |
5
|
|
|
* Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
namespace SprykerEco\Zed\ArvatoRss\Communication\Plugin\Oms\Condition; |
9
|
|
|
|
10
|
|
|
use Generated\Shared\Transfer\ArvatoRssApiCallLogTransfer; |
|
|
|
|
11
|
|
|
use Orm\Zed\Sales\Persistence\SpySalesOrderItem; |
|
|
|
|
12
|
|
|
use Spryker\Zed\Kernel\Communication\AbstractPlugin; |
13
|
|
|
use Spryker\Zed\Oms\Dependency\Plugin\Condition\ConditionInterface; |
14
|
|
|
use SprykerEco\Shared\ArvatoRss\ArvatoRssApiConfig; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* @method \SprykerEco\Zed\ArvatoRss\Business\ArvatorssFacadeInterface getFacade() |
18
|
|
|
* @method \SprykerEco\Zed\ArvatoRss\Persistence\ArvatoRssQueryContainerInterface getQueryContainer() |
19
|
|
|
* @method \SprykerEco\Zed\ArvatoRss\Persistence\ArvatoRssRepositoryInterface getRepository() |
20
|
|
|
* @method \SprykerEco\Zed\ArvatoRss\Communication\ArvatoRssCommunicationFactory getFactory() |
21
|
|
|
* @method \SprykerEco\Zed\ArvatoRss\ArvatoRssConfig getConfig() |
22
|
|
|
*/ |
23
|
|
|
class IsStoreOrderSuccessfulPlugin extends AbstractPlugin implements ConditionInterface |
24
|
|
|
{ |
25
|
|
|
/** |
26
|
|
|
* @api |
27
|
|
|
* |
28
|
|
|
* @param \Orm\Zed\Sales\Persistence\SpySalesOrderItem $orderItem |
29
|
|
|
* |
30
|
|
|
* @return bool |
31
|
|
|
*/ |
32
|
|
|
public function check(SpySalesOrderItem $orderItem): bool |
33
|
|
|
{ |
34
|
|
|
return $this->isStoreOrderSuccessful( |
35
|
|
|
$orderItem |
36
|
|
|
->getOrder() |
37
|
|
|
->getOrderReference() |
38
|
|
|
); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @param string $orderReference |
43
|
|
|
* |
44
|
|
|
* @return bool |
45
|
|
|
*/ |
46
|
|
|
protected function isStoreOrderSuccessful(string $orderReference): bool |
47
|
|
|
{ |
48
|
|
|
$storeOrderApiCallLogTransfer = $this->getApiCallLogEntry($orderReference); |
49
|
|
|
|
50
|
|
|
if ($storeOrderApiCallLogTransfer === null) { |
51
|
|
|
return false; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
return $this->isTransactionSuccessful($storeOrderApiCallLogTransfer); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @param string $orderReference |
59
|
|
|
* |
60
|
|
|
* @return \Generated\Shared\Transfer\ArvatoRssApiCallLogTransfer|null |
61
|
|
|
*/ |
62
|
|
|
protected function getApiCallLogEntry(string $orderReference): ?ArvatoRssApiCallLogTransfer |
63
|
|
|
{ |
64
|
|
|
return $this->getRepository() |
65
|
|
|
->findApiLogByOrderReferenceAndType( |
66
|
|
|
$orderReference, |
67
|
|
|
ArvatoRssApiConfig::TRANSACTION_TYPE_STORE_ORDER |
68
|
|
|
); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @param \Generated\Shared\Transfer\ArvatoRssApiCallLogTransfer $arvatoRssApiCallLogTransfer |
73
|
|
|
* |
74
|
|
|
* @return bool |
75
|
|
|
*/ |
76
|
|
|
protected function isTransactionSuccessful(ArvatoRssApiCallLogTransfer $arvatoRssApiCallLogTransfer) |
77
|
|
|
{ |
78
|
|
|
return $arvatoRssApiCallLogTransfer->getResultCode() == ArvatoRssApiConfig::RESULT_CODE_SUCCESS; |
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
|
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