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/mageworx/module-seoall/Ui/Component/Listing/Column/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/old/vendor/mageworx/module-seoall/Ui/Component/Listing/Column/Category.php
<?php
/**
 * Copyright © MageWorx. All rights reserved.
 * See LICENSE.txt for license details.
 */
namespace MageWorx\SeoAll\Ui\Component\Listing\Column;

class Category extends \Magento\Ui\Component\Listing\Columns\Column
{
    /**
     * URL builder
     *
     * @var \Magento\Framework\UrlInterface
     */
    protected $urlBuilder;

    /**
     * @var \MageWorx\SeoRedirects\Model\Redirect\Source\Category
     */
    protected $categoryOptions;

    /**
     * @var string
     */
    protected $targetField;

    /**
     * @var boolean
     */
    protected $showTitleForUnknownCategory;

    /**
     * Constructor
     *
     * @param \Magento\Framework\UrlInterface $urlBuilder
     * @param \Magento\Framework\View\Element\UiComponent\ContextInterface $context
     * @param \Magento\Framework\View\Element\UiComponentFactory $uiComponentFactory
     * @param boolean $showTitleForUnknownCategory
     * @param string $targetField
     * @param array $components
     * @param array $data
     */
    public function __construct(
        \Magento\Framework\UrlInterface $urlBuilder,
        \MageWorx\SeoAll\Model\Source\Category $categoryOptions,
        \Magento\Framework\View\Element\UiComponent\ContextInterface $context,
        \Magento\Framework\View\Element\UiComponentFactory $uiComponentFactory,
        $showTitleForUnknownCategory = true,
        $targetField = 'category_id',
        array $components = [],
        array $data = []
    ) {
        $this->categoryOptions = $categoryOptions;
        $this->urlBuilder = $urlBuilder;
        $this->showTitleForUnknownCategory = $showTitleForUnknownCategory;
        $this->targetField = $targetField;

        if (!empty($data['targetField'])) {
            $this->targetField = $data['targetField'];
        }
        parent::__construct($context, $uiComponentFactory, $components, $data);
    }

    /**
     * Prepare Data Source
     *
     * @param array $dataSource
     * @return array
     * @throws \Magento\Framework\Exception\NoSuchEntityException
     */
    public function prepareDataSource(array $dataSource)
    {
        $categoryOptions = $this->categoryOptions->getCategoryNames(\Magento\Store\Model\Store::DEFAULT_STORE_ID);

        if (isset($dataSource['data']['items'])) {
            foreach ($dataSource['data']['items'] as & $item) {
                if (!isset($item[$this->targetField])) {
                    continue;
                }

                if (!empty($categoryOptions[$item[$this->targetField]])) {
                    $item[$this->getData('name')] =
                        str_replace('(ID#', '<br> (ID#', $categoryOptions[$item[$this->targetField]]);
                } else if ($this->showTitleForUnknownCategory) {
                    $item[$this->getData('name')] = __('UNKNOWN CATEGORY') . ' (ID#' . $item[$this->targetField] . ')';
                }
            }
        }
        return $dataSource;
    }
}

Spamworldpro Mini