42 lines
1.2 KiB
PHP
42 lines
1.2 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()
|
|
{
|
|
$tunnelId = trim((string) $this->getRequest()->getParam('tunnel_id', ''));
|
|
$resultJson = $this->resultFactory->create(ResultFactory::TYPE_JSON);
|
|
if ($tunnelId !== '') {
|
|
$resultJson->setData($this->tunnelStatus->getStatus($tunnelId));
|
|
return $resultJson;
|
|
}
|
|
$resultJson->setData([
|
|
'tunnels' => $this->tunnelStatus->getAllTunnelStatuses(),
|
|
]);
|
|
return $resultJson;
|
|
}
|
|
|
|
protected function _isAllowed()
|
|
{
|
|
return $this->_authorization->isAllowed('MageSail_Magesail::tunnel')
|
|
|| $this->_authorization->isAllowed('MageSail_Magesail::tunnel_view')
|
|
|| $this->_authorization->isAllowed('MageSail_Magesail::tunnel_manage');
|
|
}
|
|
}
|