Skip to content

Commit d9fb06a

Browse files
author
Korshenko, Olexii(okorshenko)
committed
Merge pull request #5 from magento-dragons/product-video-PR3
[EPAM ]Product video LESS
2 parents e4716a3 + cdf245f commit d9fb06a

File tree

18 files changed

+501
-370
lines changed

18 files changed

+501
-370
lines changed

app/code/Magento/ProductVideo/Block/Adminhtml/Product/Edit/NewVideo.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,19 @@
1212
*/
1313
class NewVideo extends \Magento\Backend\Block\Widget\Form\Generic
1414
{
15+
/**
16+
* @var \Magento\ProductVideo\Helper\Media
17+
*/
18+
protected $mediaHelper;
19+
1520
/**
1621
* @var \Magento\Framework\Json\EncoderInterface
1722
*/
1823
protected $jsonEncoder;
1924

2025
/**
2126
* @param \Magento\Backend\Block\Template\Context $context
27+
* @param \Magento\ProductVideo\Helper\Media $mediaHelper
2228
* @param \Magento\Framework\Json\EncoderInterface $jsonEncoder
2329
* @param \Magento\Framework\Registry $registry
2430
* @param \Magento\Framework\Data\FormFactory $formFactory
@@ -29,9 +35,11 @@ public function __construct(
2935
\Magento\Framework\Registry $registry,
3036
\Magento\Framework\Data\FormFactory $formFactory,
3137
\Magento\Framework\Json\EncoderInterface $jsonEncoder,
38+
\Magento\ProductVideo\Helper\Media $mediaHelper,
3239
array $data = []
3340
) {
3441
parent::__construct($context, $registry, $formFactory, $data);
42+
$this->mediaHelper = $mediaHelper;
3543
$this->jsonEncoder = $jsonEncoder;
3644
$this->setUseContainer(true);
3745
}
@@ -171,6 +179,11 @@ protected function _prepareForm()
171179
$this->setForm($form);
172180
}
173181

182+
/**
183+
* Get html id
184+
*
185+
* @return mixed
186+
*/
174187
public function getHtmlId()
175188
{
176189
if (null === $this->getData('id')) {
@@ -180,6 +193,8 @@ public function getHtmlId()
180193
}
181194

182195
/**
196+
* Get widget options
197+
*
183198
* @return string
184199
*/
185200
public function getWidgetOptions()
@@ -189,6 +204,7 @@ public function getWidgetOptions()
189204
'saveVideoUrl' => $this->getUrl('catalog/product_gallery/upload'),
190205
'saveRemoteVideoUrl' => $this->getUrl('product_video/product_gallery/retrieveImage'),
191206
'htmlId' => $this->getHtmlId(),
207+
'youTubeApiKey' => $this->mediaHelper->getYouTubeApiKey()
192208
]
193209
);
194210
}
@@ -214,8 +230,9 @@ protected function getProduct()
214230
*/
215231
protected function addMediaRoleAttributes(Fieldset $fieldset)
216232
{
233+
$fieldset->addField('roleLabel', 'note', ['text' => __('Role')]);
217234
$mediaRoles = $this->getProduct()->getMediaAttributes();
218-
asort($mediaRoles);
235+
ksort($mediaRoles);
219236
foreach ($mediaRoles as $mediaRole) {
220237
$fieldset->addField(
221238
'video_' . $mediaRole->getAttributeCode(),

app/code/Magento/ProductVideo/Helper/Media.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
namespace Magento\ProductVideo\Helper;
88

99
use Magento\Framework\App\Area;
10+
use Magento\Framework\App\Helper\Context;
1011
use Magento\Framework\View\ConfigInterface;
1112
use Magento\Framework\View\DesignInterface;
1213

@@ -40,6 +41,11 @@ class Media extends \Magento\Framework\App\Helper\AbstractHelper
4041
*/
4142
const MEDIA_TYPE_CONFIG_NODE = 'videos';
4243

44+
/**
45+
* Configuration path
46+
*/
47+
const XML_PATH_YOUTUBE_API_KEY = 'catalog/product_video/youtube_api_key';
48+
4349
/**
4450
* @var ConfigInterface
4551
*/
@@ -60,11 +66,14 @@ class Media extends \Magento\Framework\App\Helper\AbstractHelper
6066
/**
6167
* @param ConfigInterface $configInterface
6268
* @param DesignInterface $designInterface
69+
* @param Context $context
6370
*/
6471
public function __construct(
6572
ConfigInterface $configInterface,
66-
DesignInterface $designInterface
73+
DesignInterface $designInterface,
74+
Context $context
6775
) {
76+
parent::__construct($context);
6877
$this->viewConfig = $configInterface;
6978
$this->currentTheme = $designInterface->getDesignTheme();
7079
$this->initConfig();
@@ -139,4 +148,14 @@ public function getVideoAutoRestartAttribute()
139148
return $videoAttributes[self::NODE_CONFIG_VIDEO_AUTO_RESTART];
140149
}
141150
}
151+
152+
/**
153+
* Retrieve YouTube API key
154+
*
155+
* @return string
156+
*/
157+
public function getYouTubeApiKey()
158+
{
159+
return $this->scopeConfig->getValue(self::XML_PATH_YOUTUBE_API_KEY);
160+
}
142161
}

app/code/Magento/ProductVideo/Test/Unit/Block/Adminhtml/Product/Edit/NewVideoTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ public function testGetWidgetOptions()
8686
$value = [
8787
'saveVideoUrl' => $saveVideoUrl,
8888
'saveRemoteVideoUrl' => $saveRemoteVideoUrl,
89-
'htmlId' => 'id_' . $rand
89+
'htmlId' => 'id_' . $rand,
90+
'youTubeApiKey' => null
9091
];
9192
$this->jsonEncoderMock->expects($this->once())->method('encode')->with(
9293
$value
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright © 2015 Magento. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
9+
<system>
10+
<section id="catalog">
11+
<group id="product_video" translate="label" type="text" sortOrder="350" showInDefault="1" showInWebsite="1" showInStore="1">
12+
<label>Product Video</label>
13+
<field id="youtube_api_key" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
14+
<label>YouTube API key</label>
15+
</field>
16+
</group>
17+
</section>
18+
</system>
19+
</config>

app/code/Magento/ProductVideo/view/adminhtml/layout/catalog_product_new.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
-->
88
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="admin-2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
99
<head>
10-
<css src="Magento_ProductVideo::css/productvideo.css"/>
1110
<link src="Magento_ProductVideo::js/get-video-information.js"/>
1211
</head>
1312
<body>

app/code/Magento/ProductVideo/view/adminhtml/templates/product/edit/slideout/form.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
});
1818
});
1919
</script>
20-
<div id="video-player-preview-location">
20+
<div id="video-player-preview-location" class="video-player-sidebar">
2121
<div class="video-player-container"></div>
2222
<div class="video-information title">
2323
<label><?php /* @escapeNotVerified */ echo __('Title:') ?> </label><span></span>

0 commit comments

Comments
 (0)