13 class NewVideo extends \Magento\Backend\Block\Widget\Form\Generic
51 \
Magento\Framework\Data\FormFactory $formFactory,
58 $this->urlBuilder = $context->getUrlBuilder();
60 $this->setUseContainer(
true);
72 $form = $this->_formFactory->create([
74 'id' =>
'new_video_form',
75 'class' =>
'admin__scope-old',
76 'enctype' =>
'multipart/form-data',
79 $form->setUseContainer($this->getUseContainer());
80 $form->addField(
'new_video_messages',
'note', []);
81 $fieldset = $form->addFieldset(
'new_video_form_fieldset', []);
104 'name' =>
'video_provider',
111 'class' =>
'edited-data validate-url',
112 'label' =>
__(
'Url'),
113 'title' =>
__(
'Url'),
115 'name' =>
'video_url',
123 'class' =>
'edited-data',
124 'label' =>
__(
'Title'),
125 'title' =>
__(
'Title'),
127 'name' =>
'video_title',
134 'class' =>
'edited-data',
135 'label' =>
__(
'Description'),
136 'title' =>
__(
'Description'),
137 'name' =>
'video_description',
141 'new_video_screenshot',
144 'label' =>
__(
'Preview Image'),
145 'title' =>
__(
'Preview Image'),
150 'new_video_screenshot_preview',
153 'class' =>
'preview-image-hidden-input',
155 'name' =>
'_preview',
163 'title' =>
'Get Video Information',
164 'name' =>
'new_video_get',
165 'value' =>
__(
'Get Video Information'),
166 'class' =>
'action-default' 171 'new_video_disabled',
174 'class' =>
'edited-data',
175 'label' =>
__(
'Hide from Product Page'),
176 'title' =>
__(
'Hide from Product Page'),
177 'name' =>
'disabled',
190 if (
null === $this->
getData(
'id')) {
191 $this->
setData(
'id', $this->mathRandom->getUniqueHash(
'id_'));
203 return $this->jsonEncoder->encode(
205 'saveVideoUrl' => $this->
getUrl(
'catalog/product_gallery/upload'),
206 'saveRemoteVideoUrl' => $this->
getUrl(
'product_video/product_gallery/retrieveImage'),
208 'youTubeApiKey' => $this->mediaHelper->getYouTubeApiKey(),
221 if (!$this->
hasData(
'product')) {
222 $this->
setData(
'product', $this->_coreRegistry->registry(
'product'));
224 return $this->
getData(
'product');
235 $fieldset->
addField(
'role-label',
'note', [
'text' =>
__(
'Role')]);
236 $mediaRoles = $this->
getProduct()->getMediaAttributes();
238 foreach ($mediaRoles as $mediaRole) {
240 'video_' . $mediaRole->getAttributeCode(),
243 'class' =>
'video_image_role',
244 'label' =>
__($mediaRole->getFrontendLabel()),
245 'title' =>
__($mediaRole->getFrontendLabel()),
246 'data-role' =>
'role-type-selector',
247 'value' => $mediaRole->getAttributeCode(),
261 $result =
__(
'YouTube and Vimeo supported.');
262 if ($this->mediaHelper->getYouTubeApiKey() ===
null) {
264 'Vimeo supported.<br />' 265 .
'To add YouTube video, please <a href="%1">enter YouTube API Key</a> first.',
279 return $this->urlBuilder->getUrl(
280 'adminhtml/system_config/edit',
282 'section' =>
'catalog',
283 '_fragment' => self::PATH_ANCHOR_PRODUCT_VIDEO
getData($key='', $index=null)
addMediaRoleAttributes(Fieldset $fieldset)
getUrl($route='', $params=[])
__construct(\Magento\Backend\Block\Template\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\Data\FormFactory $formFactory, \Magento\ProductVideo\Helper\Media $mediaHelper, \Magento\Framework\Json\EncoderInterface $jsonEncoder, array $data=[])
setData($key, $value=null)
const PATH_ANCHOR_PRODUCT_VIDEO