Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Data Fields | Protected Member Functions | Protected Attributes
NewVideo Class Reference
Inheritance diagram for NewVideo:
Generic Form Widget Template Template AbstractBlock DataObject BlockInterface

Public Member Functions

 __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=[])
 
 getHtmlId ()
 
 getWidgetOptions ()
 
- Public Member Functions inherited from Generic
 __construct (\Magento\Backend\Block\Template\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\Data\FormFactory $formFactory, array $data=[])
 
- Public Member Functions inherited from Form
 __construct (\Magento\Backend\Block\Template\Context $context, array $data=[])
 
 getForm ()
 
 getFormHtml ()
 
 setForm (\Magento\Framework\Data\Form $form)
 
- Public Member Functions inherited from Widget
 getId ()
 
 getSuffixId ($suffix)
 
 getHtmlId ()
 
 getCurrentUrl ($params=[])
 
 getButtonHtml ($label, $onclick, $class='', $buttonId=null, $dataAttr=[])
 
- Public Member Functions inherited from Template
 __construct (\Magento\Backend\Block\Template\Context $context, array $data=[])
 
 getFormKey ()
 
 isOutputEnabled ($moduleName=null)
 
 getAuthorization ()
 
 getToolbar ()
 
- Public Member Functions inherited from Template
 __construct (Template\Context $context, array $data=[])
 
 setTemplateContext ($templateContext)
 
 getTemplate ()
 
 setTemplate ($template)
 
 getTemplateFile ($template=null)
 
 getArea ()
 
 assign ($key, $value=null)
 
 fetchView ($fileName)
 
 getBaseUrl ()
 
 getObjectData (\Magento\Framework\DataObject $object, $key)
 
 getCacheKeyInfo ()
 
- Public Member Functions inherited from AbstractBlock
 __construct (\Magento\Framework\View\Element\Context $context, array $data=[])
 
 getJsLayout ()
 
 getRequest ()
 
 getParentBlock ()
 
 setLayout (\Magento\Framework\View\LayoutInterface $layout)
 
 getLayout ()
 
 setNameInLayout ($name)
 
 getChildNames ()
 
 setAttribute ($name, $value=null)
 
 setChild ($alias, $block)
 
 addChild ($alias, $block, $data=[])
 
 unsetChild ($alias)
 
 unsetCallChild ($alias, $callback, $result, $params)
 
 unsetChildren ()
 
 getChildBlock ($alias)
 
 getChildHtml ($alias='', $useCache=true)
 
 getChildChildHtml ($alias, $childChildAlias='', $useCache=true)
 
 getBlockHtml ($name)
 
 insert ($element, $siblingName=0, $after=true, $alias='')
 
 append ($element, $alias='')
 
 getGroupChildNames ($groupName)
 
 getChildData ($alias, $key='')
 
 getUiId ($arg1=null, $arg2=null, $arg3=null, $arg4=null, $arg5=null)
 
 getJsId ($arg1=null, $arg2=null, $arg3=null, $arg4=null, $arg5=null)
 
 getUrl ($route='', $params=[])
 
 getViewFileUrl ($fileId, array $params=[])
 
 formatDate ( $date=null, $format=\IntlDateFormatter::SHORT, $showTime=false, $timezone=null)
 
 formatTime ( $time=null, $format=\IntlDateFormatter::SHORT, $showDate=false)
 
 getModuleName ()
 
 escapeHtml ($data, $allowedTags=null)
 
 escapeJs ($string)
 
 escapeHtmlAttr ($string, $escapeSingleQuote=true)
 
 escapeCss ($string)
 
 stripTags ($data, $allowableTags=null, $allowHtmlEntities=false)
 
 escapeUrl ($string)
 
 escapeXssInUrl ($data)
 
 escapeQuote ($data, $addSlashes=false)
 
 escapeJsQuote ($data, $quote='\'')
 
 getNameInLayout ()
 
 getCacheKeyInfo ()
 
 getCacheKey ()
 
 getVar ($name, $module=null)
 
 isScopePrivate ()
 
- Public Member Functions inherited from DataObject
 __construct (array $data=[])
 
 addData (array $arr)
 
 setData ($key, $value=null)
 
 unsetData ($key=null)
 
 getData ($key='', $index=null)
 
 getDataByPath ($path)
 
 getDataByKey ($key)
 
 setDataUsingMethod ($key, $args=[])
 
 getDataUsingMethod ($key, $args=null)
 
 hasData ($key='')
 
 toArray (array $keys=[])
 
 convertToArray (array $keys=[])
 
 toXml (array $keys=[], $rootName='item', $addOpenTag=false, $addCdata=true)
 
 convertToXml (array $arrAttributes=[], $rootName='item', $addOpenTag=false, $addCdata=true)
 
 toJson (array $keys=[])
 
 convertToJson (array $keys=[])
 
 toString ($format='')
 
 __call ($method, $args)
 
 isEmpty ()
 
 serialize ($keys=[], $valueSeparator='=', $fieldSeparator=' ', $quote='"')
 
 debug ($data=null, &$objects=[])
 
 offsetSet ($offset, $value)
 
 offsetExists ($offset)
 
 offsetUnset ($offset)
 
 offsetGet ($offset)
 
- Public Member Functions inherited from BlockInterface
 toHtml ()
 

Data Fields

const PATH_ANCHOR_PRODUCT_VIDEO = 'catalog_product_video-link'
 
- Data Fields inherited from Template
const XML_PATH_TEMPLATE_ALLOW_SYMLINK = 'dev/template/allow_symlink'
 
- Data Fields inherited from AbstractBlock
const CACHE_GROUP = \Magento\Framework\App\Cache\Type\Block::TYPE_IDENTIFIER
 
const CACHE_KEY_PREFIX = 'BLOCK_'
 

Protected Member Functions

 getProduct ()
 
 addMediaRoleAttributes (Fieldset $fieldset)
 
 getNoteVideoUrl ()
 
 getConfigApiKeyUrl ()
 
- Protected Member Functions inherited from Form
 _construct ()
 
 _prepareLayout ()
 
 _prepareForm ()
 
 _beforeToHtml ()
 
 _initFormValues ()
 
 _setFieldset ($attributes, $fieldset, $exclude=[])
 
 _isAttributeVisible (\Magento\Eav\Model\Entity\Attribute $attribute)
 
 _applyTypeSpecificConfig ($inputType, $element, \Magento\Eav\Model\Entity\Attribute $attribute)
 
 _addElementTypes (\Magento\Framework\Data\Form\AbstractForm $baseElement)
 
 _getAdditionalElementTypes ()
 
 _getAdditionalElementHtml ($element)
 
- Protected Member Functions inherited from Widget
 _addBreadcrumb ($label, $title=null, $link=null)
 
- Protected Member Functions inherited from Template
 _toHtml ()
 
- Protected Member Functions inherited from Template
 _construct ()
 
 _toHtml ()
 
 getRootDirectory ()
 
 getMediaDirectory ()
 
- Protected Member Functions inherited from AbstractBlock
 _construct ()
 
 _prepareLayout ()
 
 _beforeToHtml ()
 
 _afterToHtml ($html)
 
 _toHtml ()
 
 _getNotFoundUrl ($route='', $params=['_direct'=> 'core/index/notFound'])
 
 getCacheTags ()
 
 getCacheLifetime ()
 
 _loadCache ()
 
 _saveCache ($data)
 
 _getSidPlaceholder ($cacheKey=null)
 
- Protected Member Functions inherited from DataObject
 _getData ($key)
 
 _underscore ($name)
 

Protected Attributes

 $mediaHelper
 
 $urlBuilder
 
 $jsonEncoder
 
 $videoSelector = '#media_gallery_content'
 
- Protected Attributes inherited from Generic
 $_formFactory
 
 $_coreRegistry
 
- Protected Attributes inherited from Form
 $_form
 
 $_template = 'Magento_Backend::widget/form.phtml'
 
- Protected Attributes inherited from Template
 $_authorization
 
 $mathRandom
 
 $_backendSession
 
 $formKey
 
 $nameBuilder
 
- Protected Attributes inherited from Template
 $_viewVars = []
 
 $_baseUrl
 
 $_jsUrl
 
 $_allowSymlinks
 
 $_filesystem
 
 $_template
 
 $templateEnginePool
 
 $_storeManager
 
 $_appState
 
 $directory
 
 $templateContext
 
 $pageConfig
 
 $resolver
 
 $validator
 
- Protected Attributes inherited from AbstractBlock
 $_design
 
 $_session
 
 $_sidResolver
 
 $_nameInLayout
 
 $_layout
 
 $jsLayout = []
 
 $_request
 
 $_urlBuilder
 
 $_eventManager
 
 $_frontController
 
 $_assetRepo
 
 $_viewConfig
 
 $_cacheState
 
 $_logger
 
 $_escaper
 
 $filterManager
 
 $_localeDate
 
 $inlineTranslation
 
 $_isScopePrivate = false
 
 $_scopeConfig
 
 $_cache
 
- Protected Attributes inherited from DataObject
 $_data = []
 

Additional Inherited Members

- Static Public Member Functions inherited from AbstractBlock
static extractModuleName ($className)
 
- Static Protected Attributes inherited from DataObject
static $_underscoreCache = []
 

Detailed Description

@SuppressWarnings(PHPMD.DepthOfInheritance)

Definition at line 13 of file NewVideo.php.

Constructor & Destructor Documentation

◆ __construct()

__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 = [] 
)
Parameters
\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

Definition at line 48 of file NewVideo.php.

55  {
56  parent::__construct($context, $registry, $formFactory, $data);
57  $this->mediaHelper = $mediaHelper;
58  $this->urlBuilder = $context->getUrlBuilder();
59  $this->jsonEncoder = $jsonEncoder;
60  $this->setUseContainer(true);
61  }

Member Function Documentation

◆ addMediaRoleAttributes()

addMediaRoleAttributes ( Fieldset  $fieldset)
protected

Add media role attributes to fieldset

Parameters
Fieldset$fieldset
Returns
$this

Definition at line 233 of file NewVideo.php.

234  {
235  $fieldset->addField('role-label', 'note', ['text' => __('Role')]);
236  $mediaRoles = $this->getProduct()->getMediaAttributes();
237  ksort($mediaRoles);
238  foreach ($mediaRoles as $mediaRole) {
239  $fieldset->addField(
240  'video_' . $mediaRole->getAttributeCode(),
241  'checkbox',
242  [
243  'class' => 'video_image_role',
244  'label' => __($mediaRole->getFrontendLabel()),
245  'title' => __($mediaRole->getFrontendLabel()),
246  'data-role' => 'role-type-selector',
247  'value' => $mediaRole->getAttributeCode(),
248  ]
249  );
250  }
251  return $this;
252  }
__()
Definition: __.php:13

◆ getConfigApiKeyUrl()

getConfigApiKeyUrl ( )
protected

Get url for config params

Returns
string

Definition at line 277 of file NewVideo.php.

278  {
279  return $this->urlBuilder->getUrl(
280  'adminhtml/system_config/edit',
281  [
282  'section' => 'catalog',
283  '_fragment' => self::PATH_ANCHOR_PRODUCT_VIDEO
284  ]
285  );
286  }

◆ getHtmlId()

getHtmlId ( )

Get html id

Returns
mixed

Definition at line 188 of file NewVideo.php.

189  {
190  if (null === $this->getData('id')) {
191  $this->setData('id', $this->mathRandom->getUniqueHash('id_'));
192  }
193  return $this->getData('id');
194  }
getData($key='', $index=null)
Definition: DataObject.php:119
setData($key, $value=null)
Definition: DataObject.php:72

◆ getNoteVideoUrl()

getNoteVideoUrl ( )
protected

Get note for video url

Returns
\Magento\Framework\Phrase

Definition at line 259 of file NewVideo.php.

260  {
261  $result = __('YouTube and Vimeo supported.');
262  if ($this->mediaHelper->getYouTubeApiKey() === null) {
263  $result = __(
264  'Vimeo supported.<br />'
265  . 'To add YouTube video, please <a href="%1">enter YouTube API Key</a> first.',
266  $this->getConfigApiKeyUrl()
267  );
268  }
269  return $result;
270  }
__()
Definition: __.php:13

◆ getProduct()

getProduct ( )
protected

Retrieve currently viewed product object

Returns
\Magento\Catalog\Model\Product

Definition at line 219 of file NewVideo.php.

220  {
221  if (!$this->hasData('product')) {
222  $this->setData('product', $this->_coreRegistry->registry('product'));
223  }
224  return $this->getData('product');
225  }
getData($key='', $index=null)
Definition: DataObject.php:119
setData($key, $value=null)
Definition: DataObject.php:72

◆ getWidgetOptions()

getWidgetOptions ( )

Get widget options

Returns
string

Definition at line 201 of file NewVideo.php.

202  {
203  return $this->jsonEncoder->encode(
204  [
205  'saveVideoUrl' => $this->getUrl('catalog/product_gallery/upload'),
206  'saveRemoteVideoUrl' => $this->getUrl('product_video/product_gallery/retrieveImage'),
207  'htmlId' => $this->getHtmlId(),
208  'youTubeApiKey' => $this->mediaHelper->getYouTubeApiKey(),
209  'videoSelector' => $this->videoSelector
210  ]
211  );
212  }

Field Documentation

◆ $jsonEncoder

$jsonEncoder
protected

Definition at line 33 of file NewVideo.php.

◆ $mediaHelper

$mediaHelper
protected

Definition at line 23 of file NewVideo.php.

◆ $urlBuilder

$urlBuilder
protected

Definition at line 28 of file NewVideo.php.

◆ $videoSelector

$videoSelector = '#media_gallery_content'
protected

Definition at line 38 of file NewVideo.php.

◆ PATH_ANCHOR_PRODUCT_VIDEO

const PATH_ANCHOR_PRODUCT_VIDEO = 'catalog_product_video-link'

Anchor is product video

Definition at line 18 of file NewVideo.php.


The documentation for this class was generated from the following file: