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-csp/Model/Collector/CspWhitelistXml/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/old/vendor/magento/module-csp/Model/Collector/CspWhitelistXml/FileResolver.php
<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

declare(strict_types=1);

namespace Magento\Csp\Model\Collector\CspWhitelistXml;

use Magento\Framework\Config\FileResolverInterface;
use Magento\Framework\Filesystem;
use Magento\Framework\View\Design\ThemeInterface;
use Magento\Framework\View\DesignInterface;
use Magento\Framework\View\Design\Theme\CustomizationInterface;
use Magento\Framework\View\Design\Theme\CustomizationInterfaceFactory;
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\Filesystem\Directory\ReadInterface as DirectoryRead;
use Magento\Framework\Config\CompositeFileIteratorFactory;

/**
 * Combines configuration files from both modules and current theme.
 */
class FileResolver implements FileResolverInterface
{
    /**
     * @var FileResolverInterface
     */
    private $moduleFileResolver;

    /**
     * @var ThemeInterface
     */
    private $theme;

    /**
     * @var CustomizationInterfaceFactory
     */
    private $themeInfoFactory;

    /**
     * @var DirectoryRead
     */
    private $rootDir;

    /**
     * @var CompositeFileIteratorFactory
     */
    private $iteratorFactory;

    /**
     * @param FileResolverInterface $moduleFileResolver
     * @param DesignInterface $design
     * @param CustomizationInterfaceFactory $customizationFactory
     * @param Filesystem $filesystem
     * @param CompositeFileIteratorFactory $iteratorFactory
     */
    public function __construct(
        FileResolverInterface $moduleFileResolver,
        DesignInterface $design,
        CustomizationInterfaceFactory $customizationFactory,
        Filesystem $filesystem,
        CompositeFileIteratorFactory $iteratorFactory
    ) {
        $this->moduleFileResolver = $moduleFileResolver;
        $this->theme = $design->getDesignTheme();
        $this->themeInfoFactory = $customizationFactory;
        $this->rootDir = $filesystem->getDirectoryRead(DirectoryList::ROOT);
        $this->iteratorFactory = $iteratorFactory;
    }

    /**
     * @inheritDoc
     */
    public function get($filename, $scope)
    {
         $configs = $this->moduleFileResolver->get($filename, $scope);
        if ($scope === 'global') {
            $files = [];
            $theme = $this->theme;
            while ($theme) {
                /** @var CustomizationInterface $info */
                $info = $this->themeInfoFactory->create(['theme' => $theme]);
                $file = $info->getThemeFilesPath() .'/etc/' .$filename;
                if ($this->rootDir->isExist($file)) {
                    $files[] = $file;
                }
                $theme = $theme->getParentTheme();
            }
            $configs = $this->iteratorFactory->create(
                ['paths' => array_reverse($files), 'existingIterator' => $configs]
            );
        }

        return $configs;
    }
}

Spamworldpro Mini