Skip to content

Commit 2e72fb0

Browse files
committed
Remove Zend_Json call from js/customer-data/invalidation-rules.phtml
- remove zend call and use the Magento Framework, - move work from template into app/code/Magento/Customer/Block/CustomerScopeData.php
1 parent ce5dbd5 commit 2e72fb0

File tree

2 files changed

+28
-14
lines changed

2 files changed

+28
-14
lines changed

app/code/Magento/Customer/Block/CustomerScopeData.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,30 @@ public function getWebsiteId()
5050
{
5151
return (int)$this->_storeManager->getStore()->getWebsiteId();
5252
}
53+
54+
/**
55+
* Get the invalidation rules json encoded
56+
*
57+
* @return string
58+
*/
59+
public function getInvalidationRulesJson()
60+
{
61+
return $this->jsonEncoder->encode(
62+
[
63+
'*' => [
64+
'Magento_Customer/js/invalidation-processor' => [
65+
'invalidationRules' => [
66+
'website-rule' => [
67+
'Magento_Customer/js/invalidation-rules/website-rule' => [
68+
'scopeConfig' => [
69+
'websiteId' => $this->getWebsiteId(),
70+
]
71+
]
72+
]
73+
]
74+
]
75+
],
76+
]
77+
);
78+
}
5379
}

app/code/Magento/Customer/view/frontend/templates/js/customer-data/invalidation-rules.phtml

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,6 @@
1212
<script type="text/x-magento-init">
1313
<?php
1414
/* @noEscape */
15-
echo \Zend_Json::encode([
16-
'*' => ['Magento_Customer/js/invalidation-processor' => [
17-
'invalidationRules' => [
18-
'website-rule' => [
19-
'Magento_Customer/js/invalidation-rules/website-rule' => [
20-
'scopeConfig' => [
21-
'websiteId' => $block->getWebsiteId(),
22-
]
23-
]
24-
]
25-
]
26-
]],
27-
]);
28-
?>
15+
echo $block->getInvalidationRulesJson();
16+
?>
2917
</script>

0 commit comments

Comments
 (0)