![]() 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/magento/module-customer/Ui/Component/Listing/Column/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ namespace Magento\Customer\Ui\Component\Listing\Column; use Magento\Framework\View\Element\UiComponent\ContextInterface; use Magento\Framework\View\Element\UiComponentFactory; use Magento\Ui\Component\Listing\Columns\Column; use Magento\Customer\Ui\Component\Listing\AttributeRepository; use Magento\Customer\Api\Data\AttributeMetadataInterface as AttributeMetadata; class AttributeColumn extends Column { /** * @var \Magento\Customer\Ui\Component\Listing\AttributeRepository */ protected $attributeRepository; /** * @param ContextInterface $context * @param UiComponentFactory $uiComponentFactory * @param AttributeRepository $attributeRepository * @param array $components * @param array $data */ public function __construct( ContextInterface $context, UiComponentFactory $uiComponentFactory, AttributeRepository $attributeRepository, array $components = [], array $data = [] ) { parent::__construct($context, $uiComponentFactory, $components, $data); $this->attributeRepository = $attributeRepository; } /** * Prepare Data Source * * @param array $dataSource * @return array */ public function prepareDataSource(array $dataSource) { $metaData = $this->attributeRepository->getMetadataByCode($this->getName()); if ($metaData && count($metaData[AttributeMetadata::OPTIONS])) { foreach ($dataSource['data']['items'] as &$item) { if (!isset($item[$this->getName()])) { continue; } foreach ($metaData[AttributeMetadata::OPTIONS] as $option) { if ($option['value'] == $item[$this->getName()]) { $item[$this->getName()] = $option['label']; break; } } } } return $dataSource; } }