39 lines
1.1 KiB
PHP
39 lines
1.1 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
namespace MageSail\Magesail\Controller\Adminhtml\Tunnel;
|
|
|
|
use Magento\Backend\App\Action;
|
|
use Magento\Backend\App\Action\Context;
|
|
use Magento\Framework\Controller\ResultFactory;
|
|
use MageSail\Magesail\Model\TunnelStatus;
|
|
|
|
class Status extends Action
|
|
{
|
|
public function __construct(
|
|
Context $context,
|
|
private readonly TunnelStatus $tunnelStatus
|
|
) {
|
|
parent::__construct($context);
|
|
}
|
|
|
|
public function execute()
|
|
{
|
|
$formKey = $this->getRequest()->getParam('form_key');
|
|
if (!$formKey || $formKey !== $this->_formKey->getFormKey()) {
|
|
return $this->resultFactory->create(ResultFactory::TYPE_JSON)->setData([
|
|
'error' => true,
|
|
'message' => 'Invalid form key.',
|
|
])->setHttpResponseCode(403);
|
|
}
|
|
$resultJson = $this->resultFactory->create(ResultFactory::TYPE_JSON);
|
|
$resultJson->setData($this->tunnelStatus->getStatus());
|
|
return $resultJson;
|
|
}
|
|
|
|
protected function _isAllowed()
|
|
{
|
|
return $this->_authorization->isAllowed('MageSail_Magesail::tunnel');
|
|
}
|
|
}
|