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-sales-rule/Model/Coupon/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/old/vendor/magento/module-sales-rule/Model/Coupon/CaptchaConfigProvider.php
<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

declare(strict_types=1);

namespace Magento\SalesRule\Model\Coupon;

use Magento\Captcha\Model\DefaultModel;
use Magento\Store\Model\Store;
use Magento\Store\Model\StoreManagerInterface;
use Magento\Captcha\Helper\Data as Helper;
use Magento\Customer\Model\Session as CustomerSession;
use Magento\Checkout\Model\ConfigProviderInterface;

/**
 * Adds captcha data related to coupons.
 *
 * @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
 */
class CaptchaConfigProvider implements ConfigProviderInterface
{
    /**
     * @var StoreManagerInterface
     */
    private $storeManager;

    /**
     * @var Helper
     */
    private $captchaData;

    /**
     * @var CustomerSession
     */
    private $customerSession;

    /**
     * @param StoreManagerInterface $storeManager
     * @param Helper $captchaData
     * @param CustomerSession $session
     */
    public function __construct(StoreManagerInterface $storeManager, Helper $captchaData, CustomerSession $session)
    {
        $this->storeManager = $storeManager;
        $this->captchaData = $captchaData;
        $this->customerSession = $session;
    }

    /**
     * @inheritDoc
     */
    public function getConfig()
    {
        $formId = 'sales_rule_coupon_request';
        /** @var Store $store */
        $store = $this->storeManager->getStore();
        /** @var DefaultModel $captchaModel */
        $captchaModel = $this->captchaData->getCaptcha($formId);
        $login = '';
        if ($this->customerSession->isLoggedIn()) {
            $login = $this->customerSession->getCustomerData()->getEmail();
        }
        $required =  $captchaModel->isRequired($login);
        if ($required) {
            $captchaModel->generate();
            $imageSrc = $captchaModel->getImgSrc();
        } else {
            $imageSrc = '';
        }

        return [
            'captcha' => [
                $formId => [
                    'isCaseSensitive' => (bool)$captchaModel->isCaseSensitive(),
                    'imageHeight' => $captchaModel->getHeight(),
                    'imageSrc' => $imageSrc,
                    'refreshUrl' => $store->getUrl('captcha/refresh', ['_secure' => $store->isCurrentlySecure()]),
                    'isRequired' => $required,
                    'timestamp' => time()
                ]
            ]
        ];
    }
}

Spamworldpro Mini