Spamworldpro Mini Shell
Spamworldpro


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-page-builder/Ui/Component/Listing/Columns/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //home/corals/old/vendor/magento/module-page-builder/Ui/Component/Listing/Columns/BlockStatus.php
<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

declare(strict_types=1);

namespace Magento\PageBuilder\Ui\Component\Listing\Columns;

/**
 * The purpose of this class is adding value of invisible 'is_active_label'
 */
class BlockStatus extends \Magento\Ui\Component\Listing\Columns\Column
{
    /** Status column name used to get its column value */
    const SOURCE_FIELD_NAME = 'is_active';

    /**
     * Prepare Data Source
     *
     * @param array $dataSource
     * @return array
     */
    public function prepareDataSource(array $dataSource)
    {
        $dataSource = parent::prepareDataSource($dataSource);

        if (empty($dataSource['data']['items'])) {
            return $dataSource;
        }

        $fieldName = $this->getData('name');

        foreach ($dataSource['data']['items'] as &$item) {
            if (isset($item[self::SOURCE_FIELD_NAME])) {
                $item[$fieldName] = $this->getOptionText($item[self::SOURCE_FIELD_NAME]);
            }
        }

        return $dataSource;
    }

    /**
     * Returns option text by option value
     *
     * @param int $item
     * @return string|null
     */
    private function getOptionText($item)
    {
        $statusesArray = [
            \Magento\Cms\Model\Block::STATUS_ENABLED => __('Active'),
            \Magento\Cms\Model\Block::STATUS_DISABLED => __('Inactive')
        ];
        return isset($statusesArray[$item]) ? $statusesArray[$item]: null;
    }
}

Spamworldpro Mini