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/app/code/Amasty/MWishlist/Controller/Product/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/cartforge.co/app/code/Amasty/MWishlist/Controller/Product/Search.php
<?php

declare(strict_types=1);

/**
 * @author Amasty Team
 * @copyright Copyright (c) Amasty (https://www.amasty.com)
 * @package Multiple Wishlist for Magento 2
 */

namespace Amasty\MWishlist\Controller\Product;

use Amasty\MWishlist\Controller\AbstractIndexInterface;
use Amasty\MWishlist\Model\Product\Search as SearchModel;
use Exception;
use InvalidArgumentException;
use Magento\Framework\App\Action\Action;
use Magento\Framework\App\Action\Context;
use Magento\Framework\Controller\Result\Json;
use Magento\Framework\Controller\ResultFactory;
use Magento\Framework\Controller\ResultInterface;
use Magento\Framework\Exception\LocalizedException;
use Psr\Log\LoggerInterface;

class Search extends Action implements AbstractIndexInterface
{
    /**
     * @var SearchModel
     */
    private $search;

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

    public function __construct(
        SearchModel $search,
        Context $context,
        LoggerInterface $logger
    ) {
        $this->search = $search;
        $this->logger = $logger;
        parent::__construct($context);
    }

    /**
     * @return ResultInterface
     */
    public function execute()
    {
        /** @var Json $resultJson */
        $resultJson = $this->resultFactory->create(ResultFactory::TYPE_JSON);
        try {
            $resultData = $this->getSearchModel()->search($this->getRequest()->getParam('q', ''));
            $resultJson->setData(['items' => $resultData]);
        } catch (InvalidArgumentException | LocalizedException $e) {
            $resultJson->setData(['error' => $e->getMessage()]);
        } catch (Exception $e) {
            $resultJson->setData(['error' => 'Something is wrong']);
            $this->logger->error($e->getMessage());
        }

        return $resultJson;
    }

    /**
     * @return SearchModel
     */
    private function getSearchModel(): SearchModel
    {
        return $this->search;
    }
}

Spamworldpro Mini