1 | <?php |
||||
2 | declare(strict_types=1); |
||||
3 | /** |
||||
4 | */ |
||||
5 | |||||
6 | namespace CommerceLeague\ActiveCampaign\Observer\Sales; |
||||
7 | |||||
8 | use CommerceLeague\ActiveCampaign\Helper\Config as ConfigHelper; |
||||
9 | use CommerceLeague\ActiveCampaign\MessageQueue\Topics; |
||||
10 | use Magento\Framework\Event\Observer; |
||||
11 | use Magento\Framework\Event\ObserverInterface; |
||||
12 | use Magento\Framework\MessageQueue\PublisherInterface; |
||||
13 | use Magento\Sales\Model\Order as MagentoOrder; |
||||
14 | |||||
15 | /** |
||||
16 | * Class ExportOrderObserver |
||||
17 | */ |
||||
18 | class ExportOrderObserver implements ObserverInterface |
||||
19 | { |
||||
20 | /** |
||||
21 | * @var ConfigHelper |
||||
22 | */ |
||||
23 | private $configHelper; |
||||
24 | |||||
25 | /** |
||||
26 | * @var PublisherInterface |
||||
27 | */ |
||||
28 | private $publisher; |
||||
29 | |||||
30 | /** |
||||
31 | * @param ConfigHelper $configHelper |
||||
32 | * @param PublisherInterface $publisher |
||||
33 | */ |
||||
34 | public function __construct( |
||||
35 | ConfigHelper $configHelper, |
||||
36 | PublisherInterface $publisher |
||||
37 | ) { |
||||
38 | $this->configHelper = $configHelper; |
||||
39 | $this->publisher = $publisher; |
||||
40 | } |
||||
41 | |||||
42 | /** |
||||
43 | * @inheritDoc |
||||
44 | */ |
||||
45 | public function execute(Observer $observer) |
||||
46 | { |
||||
47 | if (!$this->configHelper->isEnabled() || !$this->configHelper->isOrderExportEnabled()) { |
||||
48 | return; |
||||
49 | } |
||||
50 | |||||
51 | /** @var MagentoOrder $magentoOrder */ |
||||
52 | $magentoOrder = $observer->getEvent()->getData('order'); |
||||
53 | |||||
54 | if ($magentoOrder->getCustomerIsGuest()) { |
||||
0 ignored issues
–
show
|
|||||
55 | return; |
||||
56 | } |
||||
57 | |||||
58 | $this->publisher->publish( |
||||
59 | Topics::SALES_ORDER_EXPORT, |
||||
60 | json_encode(['magento_order_id' => $magentoOrder->getId()]) |
||||
0 ignored issues
–
show
json_encode(array('magen...magentoOrder->getId())) of type string is incompatible with the type array|object expected by parameter $data of Magento\Framework\Messag...herInterface::publish() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
61 | ); |
||||
62 | } |
||||
63 | } |
||||
64 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
integer
values, zero is a special case, in particular the following results might be unexpected: