8
8
9
9
use Magento \Framework \App \Area ;
10
10
use Magento \Framework \App \Helper \Context ;
11
- use Magento \Framework \View \ConfigInterface ;
12
- use Magento \Framework \View \DesignInterface ;
13
11
14
12
/**
15
13
* Helper to get attributes for video
@@ -21,81 +19,37 @@ class Media extends \Magento\Framework\App\Helper\AbstractHelper
21
19
*/
22
20
const MODULE_NAME = 'Magento_ProductVideo ' ;
23
21
24
- /**
25
- * Video play attribute
26
- */
27
- const NODE_CONFIG_PLAY_IF_BASE = 'play_if_base ' ;
28
-
29
- /**
30
- * Video stop attribute
31
- */
32
- const NODE_CONFIG_SHOW_RELATED = 'show_related ' ;
33
-
34
- /**
35
- * Video color attribute
36
- */
37
- const NODE_CONFIG_VIDEO_AUTO_RESTART = 'video_auto_restart ' ;
38
-
39
- /**
40
- * Media config node
41
- */
42
- const MEDIA_TYPE_CONFIG_NODE = 'videos ' ;
43
-
44
22
/**
45
23
* Configuration path
46
24
*/
47
25
const XML_PATH_YOUTUBE_API_KEY = 'catalog/product_video/youtube_api_key ' ;
48
26
49
27
/**
50
- * @var ConfigInterface
28
+ * Configuration path for video play
51
29
*/
52
- protected $ viewConfig ;
30
+ const XML_PATH_PLAY_IF_BASE = ' catalog/product_video/play_if_base ' ;
53
31
54
32
/**
55
- * Theme
56
- *
57
- * @var DesignInterface
33
+ * Configuration path for show related
34
+ */
35
+ const XML_PATH_SHOW_RELATED = 'catalog/product_video/show_related ' ;
36
+ /**
37
+ * Configuration path for video auto restart
58
38
*/
59
- protected $ currentTheme ;
39
+ const XML_PATH_VIDEO_AUTO_RESTART = ' catalog/product_video/video_auto_restart ' ;
60
40
61
41
/**
62
- * Cached video config
42
+ * Media config node
63
43
*/
64
- protected $ cachedVideoConfig ;
44
+ const MEDIA_TYPE_CONFIG_NODE = ' videos ' ;
65
45
66
46
/**
67
- * @param ConfigInterface $configInterface
68
- * @param DesignInterface $designInterface
69
47
* @param Context $context
70
48
*/
71
49
public function __construct (
72
- ConfigInterface $ configInterface ,
73
- DesignInterface $ designInterface ,
74
50
Context $ context
75
51
) {
76
52
parent ::__construct ($ context );
77
- $ this ->viewConfig = $ configInterface ;
78
- $ this ->currentTheme = $ designInterface ->getDesignTheme ();
79
- $ this ->initConfig ();
80
- }
81
-
82
- /**
83
- * Cached video config
84
- *
85
- * @return $this
86
- */
87
- protected function initConfig ()
88
- {
89
- if ($ this ->cachedVideoConfig === null ) {
90
- $ this ->cachedVideoConfig = $ this ->viewConfig ->getViewConfig (
91
- [
92
- 'area ' => Area::AREA_FRONTEND ,
93
- 'themeModel ' => $ this ->currentTheme
94
- ]
95
- );
96
- }
97
-
98
- return $ this ;
99
53
}
100
54
101
55
/**
@@ -105,14 +59,7 @@ protected function initConfig()
105
59
*/
106
60
public function getPlayIfBaseAttribute ()
107
61
{
108
- $ videoAttributes = $ this ->cachedVideoConfig ->getMediaAttributes (
109
- self ::MODULE_NAME ,
110
- self ::MEDIA_TYPE_CONFIG_NODE ,
111
- self ::NODE_CONFIG_PLAY_IF_BASE
112
- );
113
- if (isset ($ videoAttributes [self ::NODE_CONFIG_PLAY_IF_BASE ])) {
114
- return $ videoAttributes [self ::NODE_CONFIG_PLAY_IF_BASE ];
115
- }
62
+ return $ this ->scopeConfig ->getValue (self ::XML_PATH_PLAY_IF_BASE );
116
63
}
117
64
118
65
/**
@@ -122,14 +69,7 @@ public function getPlayIfBaseAttribute()
122
69
*/
123
70
public function getShowRelatedAttribute ()
124
71
{
125
- $ videoAttributes = $ this ->cachedVideoConfig ->getMediaAttributes (
126
- self ::MODULE_NAME ,
127
- self ::MEDIA_TYPE_CONFIG_NODE ,
128
- self ::NODE_CONFIG_SHOW_RELATED
129
- );
130
- if (isset ($ videoAttributes [self ::NODE_CONFIG_SHOW_RELATED ])) {
131
- return $ videoAttributes [self ::NODE_CONFIG_SHOW_RELATED ];
132
- }
72
+ return $ this ->scopeConfig ->getValue (self ::XML_PATH_SHOW_RELATED );
133
73
}
134
74
135
75
/**
@@ -139,14 +79,7 @@ public function getShowRelatedAttribute()
139
79
*/
140
80
public function getVideoAutoRestartAttribute ()
141
81
{
142
- $ videoAttributes = $ this ->cachedVideoConfig ->getMediaAttributes (
143
- self ::MODULE_NAME ,
144
- self ::MEDIA_TYPE_CONFIG_NODE ,
145
- self ::NODE_CONFIG_VIDEO_AUTO_RESTART
146
- );
147
- if (isset ($ videoAttributes [self ::NODE_CONFIG_VIDEO_AUTO_RESTART ])) {
148
- return $ videoAttributes [self ::NODE_CONFIG_VIDEO_AUTO_RESTART ];
149
- }
82
+ return $ this ->scopeConfig ->getValue (self ::XML_PATH_VIDEO_AUTO_RESTART );
150
83
}
151
84
152
85
/**
0 commit comments