commerceleague /
magento2-module-activecampaign
| 1 | <?php |
||
| 2 | declare(strict_types=1); |
||
| 3 | /** |
||
| 4 | */ |
||
| 5 | namespace CommerceLeague\ActiveCampaign\Observer\Customer; |
||
| 6 | |||
| 7 | use CommerceLeague\ActiveCampaign\Helper\Config as ConfigHelper; |
||
| 8 | use CommerceLeague\ActiveCampaign\MessageQueue\Topics; |
||
| 9 | use Magento\Customer\Model\Customer as MagentoCustomer; |
||
| 10 | use Magento\Framework\Event\Observer; |
||
| 11 | use Magento\Framework\Event\ObserverInterface; |
||
| 12 | use Magento\Framework\MessageQueue\PublisherInterface; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * Class ExportContactObserver |
||
| 16 | */ |
||
| 17 | class ExportContactObserver implements ObserverInterface |
||
| 18 | { |
||
| 19 | /** |
||
| 20 | * @var ConfigHelper |
||
| 21 | */ |
||
| 22 | private $configHelper; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * @var PublisherInterface |
||
| 26 | */ |
||
| 27 | private $publisher; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * @param ConfigHelper $configHelper |
||
| 31 | * @param PublisherInterface $publisher |
||
| 32 | */ |
||
| 33 | public function __construct( |
||
| 34 | ConfigHelper $configHelper, |
||
| 35 | PublisherInterface $publisher |
||
| 36 | ) { |
||
| 37 | $this->configHelper = $configHelper; |
||
| 38 | $this->publisher = $publisher; |
||
| 39 | } |
||
| 40 | |||
| 41 | /** |
||
| 42 | * @param Observer $observer |
||
| 43 | */ |
||
| 44 | public function execute(Observer $observer) |
||
| 45 | { |
||
| 46 | if (!$this->configHelper->isEnabled() || !$this->configHelper->isContactExportEnabled()) { |
||
| 47 | return; |
||
| 48 | } |
||
| 49 | |||
| 50 | /** @var MagentoCustomer $magentoCustomer */ |
||
| 51 | $magentoCustomer = $observer->getEvent()->getData('customer'); |
||
| 52 | |||
| 53 | $this->publisher->publish( |
||
| 54 | Topics::CUSTOMER_CONTACT_EXPORT, |
||
| 55 | json_encode(['magento_customer_id' => $magentoCustomer->getId()]) |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 56 | ); |
||
| 57 | } |
||
| 58 | } |
||
| 59 |