Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AttributeSetText.php
Go to the documentation of this file.
1 <?php
7 
11 
16 class AttributeSetText extends \Magento\Ui\Component\Listing\Columns\Column
17 {
21  const NAME = 'attribute_set_id';
22 
28 
36  public function __construct(
40  array $components = [],
41  array $data = []
42  ) {
43  parent::__construct($context, $uiComponentFactory, $components, $data);
44 
45  $this->attributeSetRepository = $attributeSetRepository;
46  }
47 
55  public function prepareDataSource(array $dataSource)
56  {
57  $dataSource = parent::prepareDataSource($dataSource);
58 
59  if (empty($dataSource['data']['items'])) {
60  return $dataSource;
61  }
62 
63  $fieldName = $this->getData('name');
64 
65  foreach ($dataSource['data']['items'] as &$item) {
66  if (!empty($item[static::NAME])) {
67  $item[$fieldName] = $this->renderColumnText($item[static::NAME]);
68  }
69  }
70 
71  return $dataSource;
72  }
73 
81  protected function renderColumnText($attributeSetId)
82  {
83  return $this->attributeSetRepository->get($attributeSetId)->getAttributeSetName();
84  }
85 }
__construct(ContextInterface $context, UiComponentFactory $uiComponentFactory, AttributeSetRepositoryInterface $attributeSetRepository, array $components=[], array $data=[])