HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux ip-172-31-42-149 5.15.0-1084-aws #91~20.04.1-Ubuntu SMP Fri May 2 07:00:04 UTC 2025 aarch64
User: ubuntu (1000)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/vhost/disk-apps/magento.bikenow.co/vendor/magento/module-csp/Model/Mode/ConfigManager.php
<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
declare(strict_types=1);

namespace Magento\Csp\Model\Mode;

use Magento\Csp\Api\Data\ModeConfiguredInterface;
use Magento\Csp\Api\ModeConfigManagerInterface;
use Magento\Csp\Model\Mode\Data\ModeConfigured;
use Magento\Framework\App\Area;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\App\State;
use Magento\Store\Model\ScopeInterface;
use Magento\Store\Model\Store;

/**
 * @inheritDoc
 */
class ConfigManager implements ModeConfigManagerInterface
{
    /**
     * @var ScopeConfigInterface
     */
    private $config;

    /**
     * @var Store
     */
    private $storeModel;

    /**
     * @var State
     */
    private $state;

    /**
     * @param ScopeConfigInterface $config
     * @param Store $store
     * @param State $state
     */
    public function __construct(ScopeConfigInterface $config, Store $store, State $state)
    {
        $this->config = $config;
        $this->storeModel = $store;
        $this->state = $state;
    }

    /**
     * @inheritDoc
     */
    public function getConfigured(): ModeConfiguredInterface
    {
        $area = $this->state->getAreaCode();
        if ($area === Area::AREA_ADMINHTML) {
            $configArea = 'admin';
        } elseif ($area === Area::AREA_FRONTEND) {
            $configArea = 'storefront';
        } else {
            throw new \RuntimeException('CSP can only be configured for storefront or admin area');
        }

        $reportOnly = $this->config->isSetFlag(
            'csp/mode/' . $configArea .'/report_only',
            ScopeInterface::SCOPE_STORE,
            $this->storeModel->getStore()
        );
        $reportUri = $this->config->getValue(
            'csp/mode/' . $configArea .'/report_uri',
            ScopeInterface::SCOPE_STORE,
            $this->storeModel->getStore()
        );

        return new ModeConfigured($reportOnly, !empty($reportUri) ? $reportUri : null);
    }
}