1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
namespace Dotdigitalgroup\Email\Plugin;
/**
* Newsletter disable susbcriber email depending on settings value.
*/
class SubscriberPlugin
{
/**
* @var \Magento\Framework\App\Config\ScopeConfigInterface
*/
public $scopeConfig;
/**
* SubscriberPlugin constructor.
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
*/
public function __construct(
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
) {
$this->scopeConfig = $scopeConfig;
}
/**
* @param \Magento\Newsletter\Model\Subscriber $subscriber
* @param callable $proceed
*
* @return mixed
*/
public function aroundSendConfirmationSuccessEmail(
\Magento\Newsletter\Model\Subscriber $subscriber,
callable $proceed
) {
$storeId = $subscriber->getStoreId();
//scope config for sending newsletter is disabled
if (! $this->scopeConfig->getValue(
\Dotdigitalgroup\Email\Helper\Config::XML_PATH_CONNECTOR_DISABLE_NEWSLETTER_SUCCESS,
'store',
$storeId
)
) {
return $proceed();
}
}
}