Skip to main content
deleted 17 characters in body
Source Link
Check this


 /**
 * @var \Magento\Framework\View\Result\PageFactory
 */
protected $resultPageFactory;

/**
 * @param \Magento\Backend\App\Action\Context $context
 * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
 */
public function __construct(
    \Magento\Backend\App\Action\Context $context,
    \Magento\Framework\View\Result\PageFactory $resultPageFactory
) {
    parent::__construct($context);
    $this->resultPageFactory = $resultPageFactory;
}

/**
 * Noroute action
 *
 * @return \Magento\Framework\Controller\ResultInterface\Magento\Backend\Model\View\Result\Page
 */
public function execute()
{
    
    /** @var \Magento\Backend\Model\View\Result\Page $resultPage */
    $resultPage = $this->resultPageFactory->create();
    $resultPage->setStatusHeader(403404, '1.1', 'Forbidden''Not Found');
    //$resultPage->setHeader('Status', '404 File not found');
    $resultPage->addHandle('adminhtml_denied''adminhtml_noroute');
    return $resultPage;
}
Check this


 /**
 * @var \Magento\Framework\View\Result\PageFactory
 */
protected $resultPageFactory;

/**
 * @param \Magento\Backend\App\Action\Context $context
 * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
 */
public function __construct(
    \Magento\Backend\App\Action\Context $context,
    \Magento\Framework\View\Result\PageFactory $resultPageFactory
) {
    parent::__construct($context);
    $this->resultPageFactory = $resultPageFactory;
}

/**
 * @return \Magento\Framework\Controller\ResultInterface
 */
public function execute()
{
    
    /** @var \Magento\Backend\Model\View\Result\Page $resultPage */
    $resultPage = $this->resultPageFactory->create();
    $resultPage->setStatusHeader(403, '1.1', 'Forbidden');
    //$resultPage->addHandle('adminhtml_denied');
    return $resultPage;
}
Check this


 /**
 * @var \Magento\Framework\View\Result\PageFactory
 */
protected $resultPageFactory;

/**
 * @param \Magento\Backend\App\Action\Context $context
 * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
 */
public function __construct(
    \Magento\Backend\App\Action\Context $context,
    \Magento\Framework\View\Result\PageFactory $resultPageFactory
) {
    parent::__construct($context);
    $this->resultPageFactory = $resultPageFactory;
}

/**
 * Noroute action
 *
 * @return \Magento\Backend\Model\View\Result\Page
 */
public function execute()
{
    /** @var \Magento\Backend\Model\View\Result\Page $resultPage */
    $resultPage = $this->resultPageFactory->create();
    $resultPage->setStatusHeader(404, '1.1', 'Not Found');
    $resultPage->setHeader('Status', '404 File not found');
    $resultPage->addHandle('adminhtml_noroute');
    return $resultPage;
}
deleted 17 characters in body
Source Link
Check this


use Magento\Framework\App\Response\Http as ResponseHttp;
    /**
     * @var ResponseHttp\Magento\Framework\View\Result\PageFactory
     */
    protected $_response;$resultPageFactory;

/**
 * @param \Magento\Backend\App\Action\Context $context
 * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
 */
public function __construct(
                  ResponseHttp\Magento\Backend\App\Action\Context $response$context,
               \Magento\Framework\View\Result\PageFactory $resultPageFactory
) {
                parent::__construct($context);
    $this->_response>resultPageFactory = $response;$resultPageFactory;
                }
        
/**
 * @return \Magento\Framework\Controller\ResultInterface
 */
public function execute()
        {
    {
    /** @var \Magento\Backend\Model\View\Result\Page $resultPage */
    $resultPage = $this->_response>resultPageFactory->setHttpResponseCode>create(500);
            $this->_response$resultPage->setHeader>setStatusHeader('Content-Type'403, 'text/plain');
           '1.1', $this->_response->setBody($exception'Forbidden');
            $this->_response//$resultPage->sendResponse>addHandle('adminhtml_denied');
           return $resultPage;
            }
Check this


use Magento\Framework\App\Response\Http as ResponseHttp;
    /**
     * @var ResponseHttp
     */
    protected $_response;

        public function __construct(
                  ResponseHttp $response,
                ) {
                    $this->_response = $response;
                }
            public function execute()
            {
              $this->_response->setHttpResponseCode(500);
            $this->_response->setHeader('Content-Type', 'text/plain');
            $this->_response->setBody($exception);
            $this->_response->sendResponse();
            
            }
Check this


 /**
 * @var \Magento\Framework\View\Result\PageFactory
 */
protected $resultPageFactory;

/**
 * @param \Magento\Backend\App\Action\Context $context
 * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
 */
public function __construct(
    \Magento\Backend\App\Action\Context $context,
    \Magento\Framework\View\Result\PageFactory $resultPageFactory
) {
    parent::__construct($context);
    $this->resultPageFactory = $resultPageFactory;
}

/**
 * @return \Magento\Framework\Controller\ResultInterface
 */
public function execute()
{
    
    /** @var \Magento\Backend\Model\View\Result\Page $resultPage */
    $resultPage = $this->resultPageFactory->create();
    $resultPage->setStatusHeader(403, '1.1', 'Forbidden');
    //$resultPage->addHandle('adminhtml_denied');
    return $resultPage;
}
added 267 characters in body
Source Link
Check this 


use Magento\Framework\App\Response\Http as ResponseHttp;
    /**
     * @var ResponseHttp
     */
    protected $_response;

        public function __construct(
               \Magento\Framework\App\Response\Http $http  ResponseHttp $response,
                ) {
                    $this->http>_response = $http;$response;
                }
            public function execute()
        {
      {
   $response = [];
         $this->http->getHeaders()>_response->clearHeaders>setHttpResponseCode(500);
            $this->http>_response->setHeader('Content-Type', 'application'text/json'plain');
            $this->_response->setBody($exception);
            $this->jsonEncoder>_response->jsonEncode>sendResponse($response));
            
            }
Check this

    public function __construct(
               \Magento\Framework\App\Response\Http $http
            ) {
                $this->http = $http;
            }
        public function execute()
        {
         $response = [];
         $this->http->getHeaders()->clearHeaders();
         $this->http->setHeader('Content-Type', 'application/json')->setBody($this->jsonEncoder->jsonEncode($response));
        }
Check this 


use Magento\Framework\App\Response\Http as ResponseHttp;
    /**
     * @var ResponseHttp
     */
    protected $_response;

        public function __construct(
                  ResponseHttp $response,
                ) {
                    $this->_response = $response;
                }
            public function execute()
            {
              $this->_response->setHttpResponseCode(500);
            $this->_response->setHeader('Content-Type', 'text/plain');
            $this->_response->setBody($exception);
            $this->_response->sendResponse();
            
            }
Source Link
Loading