File tree Expand file tree Collapse file tree 2 files changed +63
-0
lines changed
app/code/Magento/CustomerGraphQl Expand file tree Collapse file tree 2 files changed +63
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+ /**
3+ *
4+ * Copyright © Magento, Inc. All rights reserved.
5+ * See COPYING.txt for license details.
6+ */
7+ declare (strict_types = 1 );
8+
9+ namespace Magento \CustomerGraphQl \Model \Plugin \Customer ;
10+
11+ use Magento \Store \Model \ScopeInterface ;
12+ use Magento \Framework \App \Config \ScopeConfigInterface ;
13+
14+ /**
15+ * Plugin to update is_subscribed param according to system config
16+ */
17+ class CreateCustomerAccount
18+ {
19+ /**
20+ * Configuration path to newsletter active setting
21+ */
22+ const XML_PATH_NEWSLETTER_ACTIVE = 'newsletter/general/active ' ;
23+
24+ /**
25+ * @var ScopeConfigInterface
26+ */
27+ private $ scopeConfig ;
28+
29+ /**
30+ * CreateCustomerAccount constructor.
31+ *
32+ * @param ScopeConfigInterface $scopeConfig
33+ */
34+ public function __construct (
35+ ScopeConfigInterface $ scopeConfig
36+ ) {
37+ $ this ->scopeConfig = $ scopeConfig ;
38+ }
39+
40+ /**
41+ * Before Executing method.
42+ *
43+ * @param \Magento\CustomerGraphQl\Model\Customer\CreateCustomerAccount $subject
44+ * @param $data
45+ * @return array
46+ */
47+ public function beforeExecute (
48+ \Magento \CustomerGraphQl \Model \Customer \CreateCustomerAccount $ subject , $ data
49+ ) {
50+ if (!$ this ->scopeConfig ->getValue (
51+ self ::XML_PATH_NEWSLETTER_ACTIVE ,
52+ ScopeInterface::SCOPE_STORE
53+ )
54+ ) {
55+ $ data ['is_subscribed ' ] = false ;
56+ }
57+
58+ return [$ data ];
59+ }
60+ }
Original file line number Diff line number Diff line change 66 */
77-->
88<config xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance" xsi : noNamespaceSchemaLocation =" urn:magento:framework:ObjectManager/etc/config.xsd" >
9+ <type name =" Magento\CustomerGraphQl\Model\Customer\CreateCustomerAccount" >
10+ <plugin name =" createCustomerGraphQl" type =" Magento\CustomerGraphQl\Model\Plugin\Customer\CreateCustomerAccount" />
11+ </type >
912 <type name =" Magento\CustomerGraphQl\Model\Customer\UpdateCustomerData" >
1013 <arguments >
1114 <argument name =" restrictedKeys" xsi : type =" array" >
You can’t perform that action at this time.
0 commit comments