File tree Expand file tree Collapse file tree 4 files changed +44
-3
lines changed
app/code/Magento/Customer Expand file tree Collapse file tree 4 files changed +44
-3
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Magento \Customer \Block ;
4
+
5
+ use Magento \Customer \CustomerData \SectionPoolInterface ;
6
+ use Magento \Framework \View \Element \Block \ArgumentInterface ;
7
+
8
+ /**
9
+ * ViewModel to get sections names array.
10
+ */
11
+ class SectionsNameProvider implements ArgumentInterface
12
+ {
13
+ /**
14
+ * @var SectionPoolInterface
15
+ */
16
+ private $ sectionPool ;
17
+
18
+ /**
19
+ * @param SectionPoolInterface $sectionPool
20
+ */
21
+ public function __construct (
22
+ SectionPoolInterface $ sectionPool
23
+ ) {
24
+ $ this ->sectionPool = $ sectionPool ;
25
+ }
26
+
27
+ /**
28
+ * Return array of section names.
29
+ *
30
+ * @return array
31
+ */
32
+ public function getSectionsName ()
33
+ {
34
+ return array_keys ($ this ->sectionPool ->getSectionsData ());
35
+ }
36
+ }
Original file line number Diff line number Diff line change 44
44
template =" Magento_Customer::js/section-config.phtml" />
45
45
<block name =" customer.customer.data"
46
46
class =" Magento\Customer\Block\CustomerData"
47
- template =" Magento_Customer::js/customer-data.phtml" />
47
+ template =" Magento_Customer::js/customer-data.phtml" >
48
+ <arguments >
49
+ <argument name =" sectionsNameProvider" xsi : type =" object" >Magento\Customer\Block\SectionsNameProvider</argument >
50
+ </arguments >
51
+ </block >
48
52
<block name =" customer.data.invalidation.rules" class =" Magento\Customer\Block\CustomerScopeData"
49
53
template =" Magento_Customer::js/customer-data/invalidation-rules.phtml" />
50
54
</referenceContainer >
Original file line number Diff line number Diff line change 14
14
"expirableSectionLifetime": <?= (int )$ block ->getExpirableSectionLifetime () ?> ,
15
15
"expirableSectionNames": <?= /* @noEscape */ $ this ->helper (\Magento \Framework \Json \Helper \Data::class)->jsonEncode ($ block ->getExpirableSectionNames ()) ?> ,
16
16
"cookieLifeTime": "<?= $ block ->escapeJs ($ block ->getCookieLifeTime ()) ?> ",
17
- "updateSessionUrl": "<?= $ block ->escapeJs ($ block ->escapeUrl ($ block ->getCustomerDataUrl ('customer/account/updateSession ' ))) ?> "
17
+ "updateSessionUrl": "<?= $ block ->escapeJs ($ block ->escapeUrl ($ block ->getCustomerDataUrl ('customer/account/updateSession ' ))) ?> ",
18
+ "sectionsName": <?= $ this ->helper (\Magento \Framework \Json \Helper \Data::class)->jsonEncode ($ block ->getData ('sectionsNameProvider ' )->getSectionsName ()) ?>
18
19
}
19
20
}
20
21
}
Original file line number Diff line number Diff line change @@ -320,7 +320,7 @@ define([
320
320
var sectionDataIds ,
321
321
sectionsNamesForInvalidation ;
322
322
323
- sectionsNamesForInvalidation = _ . contains ( sectionNames , '*' ) ? buffer . keys ( ) : sectionNames ;
323
+ sectionsNamesForInvalidation = _ . contains ( sectionNames , '*' ) ? options . sectionsName : sectionNames ;
324
324
$ ( document ) . trigger ( 'customer-data-invalidate' , [ sectionsNamesForInvalidation ] ) ;
325
325
buffer . remove ( sectionsNamesForInvalidation ) ;
326
326
sectionDataIds = $ . cookieStorage . get ( 'section_data_ids' ) || { } ;
You can’t perform that action at this time.
0 commit comments