12
12
use Magento \Framework \Event \ObserverInterface ;
13
13
use Magento \Framework \UrlInterface ;
14
14
use Magento \Store \Model \ScopeInterface ;
15
+ use Magento \Newsletter \Model \Config ;
15
16
16
17
/**
17
18
* Class PredispatchNewsletterObserver
18
19
*/
19
20
class PredispatchNewsletterObserver implements ObserverInterface
20
21
{
21
22
/**
22
- * Configuration path to newsletter active setting
23
+ * @var Newsletter Config
23
24
*/
24
- const XML_PATH_NEWSLETTER_ACTIVE = ' newsletter/general/active ' ;
25
+ private $ config ;
25
26
26
27
/**
27
28
* @var ScopeConfigInterface
@@ -38,11 +39,16 @@ class PredispatchNewsletterObserver implements ObserverInterface
38
39
*
39
40
* @param ScopeConfigInterface $scopeConfig
40
41
* @param UrlInterface $url
42
+ * @param Config $config
41
43
*/
42
- public function __construct (ScopeConfigInterface $ scopeConfig , UrlInterface $ url )
43
- {
44
+ public function __construct (
45
+ ScopeConfigInterface $ scopeConfig ,
46
+ UrlInterface $ url ,
47
+ Config $ config
48
+ ) {
44
49
$ this ->scopeConfig = $ scopeConfig ;
45
50
$ this ->url = $ url ;
51
+ $ this ->config = $ config ;
46
52
}
47
53
48
54
/**
@@ -52,11 +58,7 @@ public function __construct(ScopeConfigInterface $scopeConfig, UrlInterface $url
52
58
*/
53
59
public function execute (Observer $ observer ) : void
54
60
{
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 )) {
60
62
$ defaultNoRouteUrl = $ this ->scopeConfig ->getValue (
61
63
'web/default/no_route ' ,
62
64
ScopeInterface::SCOPE_STORE
0 commit comments