Skip to content

Commit 8e07181

Browse files
committed
Set Newsletter Config
1 parent f94b4a8 commit 8e07181

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

app/code/Magento/Newsletter/Observer/PredispatchNewsletterObserver.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,17 @@
1212
use Magento\Framework\Event\ObserverInterface;
1313
use Magento\Framework\UrlInterface;
1414
use Magento\Store\Model\ScopeInterface;
15+
use Magento\Newsletter\Model\Config;
1516

1617
/**
1718
* Class PredispatchNewsletterObserver
1819
*/
1920
class PredispatchNewsletterObserver implements ObserverInterface
2021
{
2122
/**
22-
* Configuration path to newsletter active setting
23+
* @var Newsletter Config
2324
*/
24-
const XML_PATH_NEWSLETTER_ACTIVE = 'newsletter/general/active';
25+
private $config;
2526

2627
/**
2728
* @var ScopeConfigInterface
@@ -38,11 +39,16 @@ class PredispatchNewsletterObserver implements ObserverInterface
3839
*
3940
* @param ScopeConfigInterface $scopeConfig
4041
* @param UrlInterface $url
42+
* @param Config $config
4143
*/
42-
public function __construct(ScopeConfigInterface $scopeConfig, UrlInterface $url)
43-
{
44+
public function __construct(
45+
ScopeConfigInterface $scopeConfig,
46+
UrlInterface $url,
47+
Config $config
48+
) {
4449
$this->scopeConfig = $scopeConfig;
4550
$this->url = $url;
51+
$this->config = $config;
4652
}
4753

4854
/**
@@ -52,11 +58,7 @@ public function __construct(ScopeConfigInterface $scopeConfig, UrlInterface $url
5258
*/
5359
public function execute(Observer $observer) : void
5460
{
55-
if (!$this->scopeConfig->getValue(
56-
self::XML_PATH_NEWSLETTER_ACTIVE,
57-
ScopeInterface::SCOPE_STORE
58-
)
59-
) {
61+
if (!$this->config->isActive(ScopeInterface::SCOPE_STORE)) {
6062
$defaultNoRouteUrl = $this->scopeConfig->getValue(
6163
'web/default/no_route',
6264
ScopeInterface::SCOPE_STORE

0 commit comments

Comments
 (0)