Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
StatusText.php
Go to the documentation of this file.
1 <?php
7 
12 
17 class StatusText extends \Magento\Ui\Component\Listing\Columns\Column
18 {
23  protected $status;
24 
32  public function __construct(
36  array $components = [],
37  array $data = []
38  ) {
39  parent::__construct($context, $uiComponentFactory, $components, $data);
40 
41  $this->status = $status;
42  }
43 
51  public function prepareDataSource(array $dataSource)
52  {
53  $dataSource = parent::prepareDataSource($dataSource);
54 
55  if (empty($dataSource['data']['items'])) {
56  return $dataSource;
57  }
58 
59  $fieldName = $this->getData('name');
60  $sourceFieldName = ProductInterface::STATUS;
61 
62  foreach ($dataSource['data']['items'] as &$item) {
63  if (!empty($item[$sourceFieldName])) {
64  $item[$fieldName] = $this->status->getOptionText($item[$sourceFieldName]);
65  }
66  }
67 
68  return $dataSource;
69  }
70 }
__construct(ContextInterface $context, UiComponentFactory $uiComponentFactory, Status $status, array $components=[], array $data=[])
Definition: StatusText.php:32