Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Data Fields | Protected Member Functions
Thumbnail Class Reference
Inheritance diagram for Thumbnail:
Column AbstractComponent ColumnInterface DataObject UiComponentInterface UiComponentInterface BlockInterface BlockInterface

Public Member Functions

 __construct (ContextInterface $context, UiComponentFactory $uiComponentFactory, \Magento\Catalog\Helper\Image $imageHelper, \Magento\Framework\UrlInterface $urlBuilder, array $components=[], array $data=[])
 
 prepareDataSource (array $dataSource)
 
- Public Member Functions inherited from Column
 __construct (ContextInterface $context, UiComponentFactory $uiComponentFactory, array $components=[], array $data=[])
 
 getComponentName ()
 
 prepare ()
 
 prepareItems (array & $items)
 
- Public Member Functions inherited from AbstractComponent
 __construct (ContextInterface $context, array $components=[], array $data=[])
 
 getContext ()
 
 getName ()
 
 prepare ()
 
 toHtml ()
 
 render ()
 
 addComponent ($name, UiComponentInterface $component)
 
 getComponent ($name)
 
 getChildComponents ()
 
 renderChildComponent ($name)
 
 getTemplate ()
 
 getConfiguration ()
 
 getJsConfig (UiComponentInterface $component)
 
 setData ($key, $value=null)
 
 getData ($key='', $index=null)
 
 prepareDataSource (array $dataSource)
 
 getDataSourceData ()
 
- 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)
 

Data Fields

const NAME = 'thumbnail'
 
const ALT_FIELD = 'name'
 
- Data Fields inherited from Column
const NAME = 'column'
 

Protected Member Functions

 getAlt ($row)
 
- Protected Member Functions inherited from Column
 addFieldToSelect ()
 
 applySorting ()
 
- Protected Member Functions inherited from AbstractComponent
 prepareChildComponent (UiComponentInterface $component)
 
 initObservers (array & $data=[])
 
- Protected Member Functions inherited from DataObject
 _getData ($key)
 
 _underscore ($name)
 

Additional Inherited Members

- Protected Attributes inherited from Column
 $wrappedComponent
 
 $uiComponentFactory
 
- Protected Attributes inherited from AbstractComponent
 $context
 
 $components
 
 $componentData = []
 
 $dataSources = []
 
- Protected Attributes inherited from DataObject
 $_data = []
 
- Static Protected Attributes inherited from DataObject
static $_underscoreCache = []
 

Detailed Description

@api

Since
100.0.2

Definition at line 15 of file Thumbnail.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( ContextInterface  $context,
UiComponentFactory  $uiComponentFactory,
\Magento\Catalog\Helper\Image  $imageHelper,
\Magento\Framework\UrlInterface  $urlBuilder,
array  $components = [],
array  $data = [] 
)
Parameters
ContextInterface$context
UiComponentFactory$uiComponentFactory
\Magento\Catalog\Helper\Image$imageHelper
\Magento\Framework\UrlInterface$urlBuilder
array$components
array$data

Definition at line 29 of file Thumbnail.php.

36  {
37  parent::__construct($context, $uiComponentFactory, $components, $data);
38  $this->imageHelper = $imageHelper;
39  $this->urlBuilder = $urlBuilder;
40  }

Member Function Documentation

◆ getAlt()

getAlt (   $row)
protected
Parameters
array$row
Returns
null|string

Definition at line 74 of file Thumbnail.php.

75  {
76  $altField = $this->getData('config/altField') ?: self::ALT_FIELD;
77  return isset($row[$altField]) ? $row[$altField] : null;
78  }

◆ prepareDataSource()

prepareDataSource ( array  $dataSource)

Prepare Data Source

Parameters
array$dataSource
Returns
array

Implements UiComponentInterface.

Definition at line 48 of file Thumbnail.php.

49  {
50  if (isset($dataSource['data']['items'])) {
51  $fieldName = $this->getData('name');
52  foreach ($dataSource['data']['items'] as & $item) {
53  $product = new \Magento\Framework\DataObject($item);
54  $imageHelper = $this->imageHelper->init($product, 'product_listing_thumbnail');
55  $item[$fieldName . '_src'] = $imageHelper->getUrl();
56  $item[$fieldName . '_alt'] = $this->getAlt($item) ?: $imageHelper->getLabel();
57  $item[$fieldName . '_link'] = $this->urlBuilder->getUrl(
58  'catalog/product/edit',
59  ['id' => $product->getEntityId(), 'store' => $this->context->getRequestParam('store')]
60  );
61  $origImageHelper = $this->imageHelper->init($product, 'product_listing_thumbnail_preview');
62  $item[$fieldName . '_orig_src'] = $origImageHelper->getUrl();
63  }
64  }
65 
66  return $dataSource;
67  }

Field Documentation

◆ ALT_FIELD

const ALT_FIELD = 'name'

Definition at line 19 of file Thumbnail.php.

◆ NAME

const NAME = 'thumbnail'

Definition at line 17 of file Thumbnail.php.


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