![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/amasty/product-attachment/Ui/Component/Listing/Columns/Column/ |
<?php /** * @author Amasty Team * @copyright Copyright (c) Amasty (https://www.amasty.com) * @package Product Attachments Base for Magento 2 */ namespace Amasty\ProductAttachment\Ui\Component\Listing\Columns\Column; use Amasty\ProductAttachment\Api\Data\IconInterface; use Amasty\ProductAttachment\Model\Filesystem\UrlResolver; use Magento\Framework\View\Element\UiComponentFactory; use Magento\Framework\View\Element\UiComponent\ContextInterface; class Thumbnail extends \Magento\Ui\Component\Listing\Columns\Column { /** * @var UrlResolver */ private $iconUrl; public function __construct( UrlResolver $iconUrl, ContextInterface $context, UiComponentFactory $uiComponentFactory, array $components = [], array $data = [] ) { parent::__construct($context, $uiComponentFactory, $components, $data); $this->iconUrl = $iconUrl; } /** * Prepare Data Source * * @param array $dataSource * @return array */ public function prepareDataSource(array $dataSource) { if (isset($dataSource['data']['items'])) { $fieldName = $this->getData('name'); foreach ($dataSource['data']['items'] as &$item) { if (!empty($item[IconInterface::IMAGE])) { $item[$fieldName . '_src'] = $this->iconUrl->getIconUrlByName($item[IconInterface::IMAGE]); } } } return $dataSource; } }