CustomerPlugin.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace Dotdigitalgroup\Email\Plugin;
  3. /**
  4. * Disable customer email depending on settings value.
  5. */
  6. class CustomerPlugin
  7. {
  8. /**
  9. * @var \Magento\Framework\App\Config\ScopeConfigInterface
  10. */
  11. public $scopeConfig;
  12. /**
  13. * CustomerPlugin constructor.
  14. * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
  15. */
  16. public function __construct(
  17. \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
  18. ) {
  19. $this->scopeConfig = $scopeConfig;
  20. }
  21. /**
  22. * @param \Magento\Customer\Model\Customer $customer
  23. * @param callable $proceed
  24. * @param string $type
  25. * @param string $backUrl
  26. * @param string $storeId
  27. *
  28. * @return mixed
  29. */
  30. public function aroundSendNewAccountEmail(
  31. \Magento\Customer\Model\Customer $customer,
  32. callable $proceed,
  33. $type = 'registered',
  34. $backUrl = '',
  35. $storeId = '0'
  36. ) {
  37. $storeId = $customer->getStoreId();
  38. if (! $this->scopeConfig->getValue(
  39. \Dotdigitalgroup\Email\Helper\Config::XML_PATH_CONNECTOR_DISABLE_CUSTOMER_SUCCESS,
  40. 'store',
  41. $storeId
  42. )
  43. ) {
  44. return $proceed($type, $backUrl, $storeId);
  45. }
  46. }
  47. }