<?php
namespace App\Controller;
use App\RequestManager\Application\ApplicationRequestManager;
use App\RequestManager\MerchantRequestManager;
use App\RequestManager\TerminalRequestManager;
use App\RequestManager\Transaction\TransactionV2RequestManager;
use GuzzleHttp\Exception\GuzzleException;
use JsonException;
use Paynetics\Controller\AbstractApiController;
use Paynetics\Exception\ApiException;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Serializer\Exception\ExceptionInterface;
/**
* Class DashboardController
* @package App\Controller
*/
class DashboardController extends AbstractApiController
{
/**
* @var ApplicationRequestManager $service
* @required
*/
public ApplicationRequestManager $applicationRequestManager;
/**
* @var TransactionV2RequestManager
* @required
*/
public TransactionV2RequestManager $transactionRequestManager;
/**
* @var TerminalRequestManager
* @required
*/
public TerminalRequestManager $terminalRequestManager;
/**
* @var MerchantRequestManager
* @required
*/
public MerchantRequestManager $merchantRequestManager;
/**
* @return Response
* @throws GuzzleException
* @throws JsonException
* @throws ApiException
* @throws ExceptionInterface
*/
public function index(): Response
{
if ($this->isGranted('ROLE_READ_ONLY')) {
return $this->redirectToRoute('transactions');
}
$applications = $this->applicationRequestManager->getApplications(1,5);
$transactions = $this->transactionRequestManager->getTransactions(1,5);
$stores = $this->terminalRequestManager->getStores(1,5);
$merchants = $this->merchantRequestManager->getMerchants(1,5);
return $this->render('dashboard/dashboard.html.twig', [
'applications' => $applications,
'transactions' => $transactions,
'stores' => $stores,
'merchants' => $merchants,
'toolbarPage' => 'Dashboard'
]);
}
}