22/**
33 * @Author: nguyen
44 * @Date: 2020-02-12 14:01:01
5- * @Last Modified by: Alex Dong
6- * @Last Modified time: 2020-03-15 15:38:55
5+ * @Last Modified by: nguyen
6+ * @Last Modified time: 2020-03-15 18:51:36
77 */
88
99namespace Magepow \Lazyload \Helper ;
1010
1111class Data extends \Magento \Framework \App \Helper \AbstractHelper
1212{
13- const CONFIG_MODULE = 'magepow_lazyload ' ;
14-
1513 /**
1614 * @var string
1715 */
@@ -28,8 +26,8 @@ public function __construct(
2826 )
2927 {
3028 parent ::__construct ($ context );
31- $ this ->pageConfig = $ pageConfig ;
32- $ this ->configModule = $ this ->getConfig (self :: CONFIG_MODULE );
29+ $ this ->pageConfig = $ pageConfig ;
30+ $ this ->configModule = $ this ->getConfig (strtolower ( $ this -> _getModuleName ()) );
3331 }
3432
3533 public function getConfig ($ cfg ='' )
@@ -40,10 +38,19 @@ public function getConfig($cfg='')
4038
4139 public function getConfigModule ($ cfg ='' , $ value =null )
4240 {
43- $ config = explode ('/ ' , $ cfg );
44- if ( !$ cfg ) $ value = $ this ->configModule ;
45- foreach ($ config as $ key ) {
46- if (isset ($ value [$ key ])) $ value = $ value [$ key ];
41+ $ values = $ this ->configModule ;
42+ if ( !$ cfg ) return $ values ;
43+ $ config = explode ('/ ' , $ cfg );
44+ $ end = count ($ config ) - 1 ;
45+ foreach ($ config as $ key => $ vl ) {
46+ if ( isset ($ values [$ vl ]) ){
47+ if ( $ key == $ end ) {
48+ $ value = $ values [$ vl ];
49+ }else {
50+ $ values = $ values [$ vl ];
51+ }
52+ }
53+
4754 }
4855 return $ value ;
4956 }
0 commit comments