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/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/old/vendor/magento/module-csp/Model/Collector/DynamicCollector.php
<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
declare(strict_types=1);

namespace Magento\Csp\Model\Collector;

use Magento\Csp\Api\Data\PolicyInterface;
use Magento\Csp\Api\PolicyCollectorInterface;

/**
 * CSPs dynamically added during the rendering of current page (from .phtml templates for instance).
 */
class DynamicCollector implements PolicyCollectorInterface
{
    /**
     * @var PolicyInterface[]
     */
    private $added = [];

    /**
     * @var MergerInterface
     */
    private $merger;

    /**
     * @param MergerInterface $merger
     */
    public function __construct(MergerInterface $merger)
    {
        $this->merger = $merger;
    }

    /**
     * Add a policy for current page.
     *
     * @param PolicyInterface $policy
     * @return void
     */
    public function add(PolicyInterface $policy): void
    {
        if (array_key_exists($policy->getId(), $this->added)) {
            if ($this->merger->canMerge($this->added[$policy->getId()], $policy)) {
                $this->added[$policy->getId()] = $this->merger->merge($this->added[$policy->getId()], $policy);
            } else {
                throw new \RuntimeException('Cannot merge a policy of ' .get_class($policy));
            }
        } else {
            $this->added[$policy->getId()] = $policy;
        }
    }

    /**
     * @inheritDoc
     */
    public function collect(array $defaultPolicies = []): array
    {
        return array_merge($defaultPolicies, array_values($this->added));
    }
}

Spamworldpro Mini