File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <?php
2+ declare (strict_types=1 );
3+
4+ namespace Loki \Base \ViewModel ;
5+
6+ use Magento \Framework \Module \Manager ;
7+ use Magento \Framework \View \Element \Block \ArgumentInterface ;
8+
9+ class ModuleConfig implements ArgumentInterface
10+ {
11+ public function __construct (
12+ private readonly Manager $ moduleManager
13+ ) {
14+ }
15+
16+ public function isEnabled (string $ moduleName ): bool
17+ {
18+ return $ this ->moduleManager ->isEnabled ($ moduleName );
19+ }
20+ }
Original file line number Diff line number Diff line change 66 <block name =" loki.script.store.local-storage" template =" Loki_Base::script/store/localstorage-store.phtml" >
77 <arguments >
88 <argument name =" section_config" xsi : type =" object" >Loki\Base\ViewModel\SectionConfig</argument >
9+ <argument name =" module_config" xsi : type =" object" >Loki\Base\ViewModel\ModuleConfig</argument >
910 </arguments >
1011 </block >
1112 </referenceBlock >
Original file line number Diff line number Diff line change @@ -7,12 +7,17 @@ use Magento\Framework\View\Element\Template;
77/** @version 1.1.8 */
88/** @var Template $block */
99/** @var SectionConfig $sectionConfig */
10+ /** @var \Loki\Base\ViewModel\ModuleConfig $moduleConfig */
11+ if ($ moduleConfig ->isEnabled ('MageOS_AlpineLocalStorage ' )) {
12+ return ;
13+ }
1014
1115$ sectionConfig = $ block ->getSectionConfig ();
16+ $ moduleConfig = $ block ->getModuleConfig ();
1217?>
1318<script>
1419 document.addEventListener('alpine:init', () => {
15- Alpine.store('LokiLocalStorage ', {
20+ Alpine.store('LocalStorage ', {
1621 key: 'mage-cache-storage',
1722 sectionLifetime: <?= (int )$ sectionConfig ->getSectionDataLifeTime () * 60 ?> ,
1823 data: {},
@@ -25,7 +30,7 @@ $sectionConfig = $block->getSectionConfig();
2530 }
2631
2732 let changed = false;
28- const cookieSections = LokiCookies .get('section_data_ids') || {};
33+ const cookieSections = MageCookies .get('section_data_ids') || {};
2934
3035 Object.entries(this.data).forEach(([key, value]) => {
3136 const isSectionExpired = !value.data_id || parseInt(value.data_id) + this.sectionLifetime < this.getCurrentTimestamp();
You can’t perform that action at this time.
0 commit comments