| Current Path : /home/rtorresani/www/vendor/magento/module-search/Ui/Component/Listing/Column/ |
| Current File : //home/rtorresani/www/vendor/magento/module-search/Ui/Component/Listing/Column/Website.php |
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Search\Ui\Component\Listing\Column;
use Magento\Framework\Escaper;
use Magento\Framework\View\Element\UiComponent\ContextInterface;
use Magento\Framework\View\Element\UiComponentFactory;
use Magento\Store\Model\System\Store as SystemStore;
use Magento\Ui\Component\Listing\Columns\Column;
use Magento\Store\Model\StoreManagerInterface;
/**
* Class Website
*/
class Website extends Column
{
/**
* @var StoreManagerInterface
*/
protected $storeManager;
/**
* Constructor
*
* @param ContextInterface $context
* @param UiComponentFactory $uiComponentFactory
* @param StoreManagerInterface $storeManager
* @param array $components
* @param array $data
*/
public function __construct(
ContextInterface $context,
UiComponentFactory $uiComponentFactory,
StoreManagerInterface $storeManager,
array $components = [],
array $data = []
) {
$this->storeManager = $storeManager;
parent::__construct($context, $uiComponentFactory, $components, $data);
}
/**
* Prepare Data Source
*
* @param array $dataSource
* @return array
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function prepareDataSource(array $dataSource)
{
if (isset($dataSource['data']['items'])) {
foreach ($dataSource['data']['items'] as & $item) {
$item[$this->getData('name')] = $this->prepareItem($item);
}
}
return $dataSource;
}
/**
* Get data
*
* @param array $item
* @return string
* @throws \Magento\Framework\Exception\LocalizedException
*/
protected function prepareItem(array $item)
{
if ($item['website_id'] == Website\Options::ALL_WEBSITES) {
return __('All Websites');
}
return $this->storeManager->getWebsite($item['website_id'])->getName();
}
}