![]() 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-backend/Block/Widget/Grid/Column/Renderer/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ namespace Magento\Backend\Block\Widget\Grid\Column\Renderer; /** * Grid column widget for rendering grid cells that contains mapped values * * @api * @deprecated 100.2.0 in favour of UI component implementation * @since 100.0.2 */ class Options extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\Text { /** * Get options from column * * @return array */ protected function _getOptions() { return $this->getColumn()->getOptions(); } /** * Render a grid cell as options * * @param \Magento\Framework\DataObject $row * @return string|void * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ public function render(\Magento\Framework\DataObject $row) { $options = $this->_getOptions(); $showMissingOptionValues = (bool)$this->getColumn()->getShowMissingOptionValues(); if (!empty($options) && is_array($options)) { //transform option format $output = []; foreach ($options as $option) { $output[$option['value']] = $option['label']; } $value = $row->getData($this->getColumn()->getIndex()); if (is_array($value)) { $res = []; foreach ($value as $item) { if (isset($output[$item])) { $res[] = $this->escapeHtml($output[$item]); } elseif ($showMissingOptionValues) { $res[] = $this->escapeHtml($item); } } return implode(', ', $res); } elseif (isset($output[$value])) { return $this->escapeHtml($output[$value]); } elseif (in_array($value, $output)) { return $this->escapeHtml($value); } } } }