commerceleague /
magento2-module-activecampaign
| 1 | <?php |
||
| 2 | declare(strict_types=1); |
||
| 3 | /** |
||
| 4 | */ |
||
| 5 | |||
| 6 | namespace CommerceLeague\ActiveCampaign\Observer\Customer; |
||
| 7 | |||
| 8 | use CommerceLeague\ActiveCampaign\Helper\Config as ConfigHelper; |
||
| 9 | use CommerceLeague\ActiveCampaign\MessageQueue\Topics; |
||
| 10 | use Magento\Customer\Model\Customer as MagentoCustomer; |
||
| 11 | use Magento\Framework\Event\Observer; |
||
| 12 | use Magento\Framework\Event\ObserverInterface; |
||
| 13 | use Magento\Framework\MessageQueue\PublisherInterface; |
||
| 14 | |||
| 15 | /** |
||
| 16 | * Class ExportCustomerObserver |
||
| 17 | */ |
||
| 18 | class ExportCustomerObserver 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->isCustomerExportEnabled()) { |
||
| 48 | return; |
||
| 49 | } |
||
| 50 | |||
| 51 | /** @var MagentoCustomer $magentoCustomer */ |
||
| 52 | $magentoCustomer = $observer->getEvent()->getData('customer'); |
||
| 53 | |||
| 54 | $this->publisher->publish( |
||
| 55 | Topics::CUSTOMER_CUSTOMER_EXPORT, |
||
| 56 | json_encode(['magento_customer_id' => $magentoCustomer->getId()]) |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 57 | ); |
||
| 58 | } |
||
| 59 | } |
||
| 60 |