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/cartforge.co/vendor/magento/module-newsletter/Controller/Ajax/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //home/corals/cartforge.co/vendor/magento/module-newsletter/Controller/Ajax/Status.php
<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
declare(strict_types=1);

namespace Magento\Newsletter\Controller\Ajax;

use Magento\Framework\App\Action\Action;
use Magento\Framework\App\Action\Context;
use Magento\Framework\App\Action\HttpGetActionInterface;
use Magento\Framework\Controller\Result\Json;
use Magento\Framework\Controller\ResultFactory;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Validator\EmailAddress as EmailAddressValidator;
use Magento\Newsletter\Model\GuestSubscriptionChecker;
use Psr\Log\LoggerInterface;

/**
 * Newsletter subscription status verification controller.
 */
class Status extends Action implements HttpGetActionInterface
{
    /**
     * @var EmailAddressValidator
     */
    private $emailAddressValidator;

    /**
     * @var GuestSubscriptionChecker
     */
    private $guestSubscriptionChecker;

    /**
     * @var LoggerInterface
     */
    private $logger;

    /**
     * @param Context $context
     * @param EmailAddressValidator $emailAddressValidator
     * @param GuestSubscriptionChecker $guestSubscriptionChecker
     * @param LoggerInterface $logger
     */
    public function __construct(
        Context $context,
        EmailAddressValidator $emailAddressValidator,
        GuestSubscriptionChecker $guestSubscriptionChecker,
        LoggerInterface $logger
    ) {
        parent::__construct($context);
        $this->emailAddressValidator = $emailAddressValidator;
        $this->guestSubscriptionChecker = $guestSubscriptionChecker;
        $this->logger = $logger;
    }

    /**
     * @inheritdoc
     */
    public function execute()
    {
        $email = (string)$this->getRequest()->getParam('email');

        $response = [
            'subscribed' => false,
            'errors' => false,
        ];
        try {
            if (!empty($email) && $this->emailAddressValidator->isValid($email)) {
                $response['subscribed'] = $this->guestSubscriptionChecker->isSubscribed($email);
            }
        } catch (LocalizedException | \DomainException $exception) {
            $this->logger->error($exception->getMessage());
            $response['errors'] = true;
        }

        /** @var Json $resultJson */
        $resultJson = $this->resultFactory->create(ResultFactory::TYPE_JSON);

        return $resultJson->setData($response);
    }
}

Spamworldpro Mini