|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Copyright © 2016-present Spryker Systems GmbH. All rights reserved. |
|
5
|
|
|
* Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
namespace SprykerEco\Zed\PunchoutCatalogs\Communication\Controller; |
|
9
|
|
|
|
|
10
|
|
|
use Spryker\Zed\Kernel\Communication\Controller\AbstractController; |
|
11
|
|
|
use Symfony\Component\HttpFoundation\JsonResponse; |
|
12
|
|
|
use Symfony\Component\HttpFoundation\Request; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* @method \SprykerEco\Zed\PunchoutCatalogs\Persistence\PunchoutCatalogsRepositoryInterface getRepository() |
|
16
|
|
|
* @method \SprykerEco\Zed\PunchoutCatalogs\Business\PunchoutCatalogsFacadeInterface getFacade() |
|
17
|
|
|
* @method \SprykerEco\Zed\PunchoutCatalogs\Communication\PunchoutCatalogsCommunicationFactory getFactory() |
|
18
|
|
|
*/ |
|
19
|
|
|
class TransactionController extends AbstractController |
|
20
|
|
|
{ |
|
21
|
|
|
protected const PARAM_ID_PUNCHOUT_CATALOG_TRANSACTION = 'id-punchout-catalog-transaction'; |
|
22
|
|
|
protected const MESSAGE_TRANSACTION_NOT_FOUND = 'Transaction not found'; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @see \SprykerEco\Zed\PunchoutCatalogs\Communication\Controller\TransactionController::indexAction() |
|
26
|
|
|
*/ |
|
27
|
|
|
protected const ROUTE_PUNCHOUT_CATALOGS_TRANSACTION_LIST_PAGE = '/punchout-catalogs/transaction/index'; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @return array |
|
31
|
|
|
*/ |
|
32
|
|
|
public function indexAction(): array |
|
33
|
|
|
{ |
|
34
|
|
|
$table = $this->getFactory() |
|
35
|
|
|
->createPunchoutCatalogsTransactionLogTable(); |
|
36
|
|
|
|
|
37
|
|
|
return $this->viewResponse([ |
|
38
|
|
|
'table' => $table->render(), |
|
39
|
|
|
]); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* @return \Symfony\Component\HttpFoundation\JsonResponse |
|
44
|
|
|
*/ |
|
45
|
|
|
public function tableAction(): JsonResponse |
|
46
|
|
|
{ |
|
47
|
|
|
$table = $this->getFactory() |
|
48
|
|
|
->createPunchoutCatalogsTransactionLogTable(); |
|
49
|
|
|
|
|
50
|
|
|
return $this->jsonResponse($table->fetchData()); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* @param \Symfony\Component\HttpFoundation\Request $request |
|
55
|
|
|
* |
|
56
|
|
|
* @return array|\Symfony\Component\HttpFoundation\RedirectResponse |
|
57
|
|
|
*/ |
|
58
|
|
|
public function viewAction(Request $request) |
|
59
|
|
|
{ |
|
60
|
|
|
$idPunchoutCatalogTransaction = $this->castId( |
|
61
|
|
|
$request->query->get(static::PARAM_ID_PUNCHOUT_CATALOG_TRANSACTION) |
|
62
|
|
|
); |
|
63
|
|
|
|
|
64
|
|
|
$punchoutCatalogTransactionTransfer = $this->getFacade() |
|
65
|
|
|
->findTransactionById($idPunchoutCatalogTransaction); |
|
66
|
|
|
|
|
67
|
|
|
if (!$punchoutCatalogTransactionTransfer) { |
|
68
|
|
|
$this->addErrorMessage(static::MESSAGE_TRANSACTION_NOT_FOUND); |
|
69
|
|
|
|
|
70
|
|
|
return $this->redirectResponse(static::ROUTE_PUNCHOUT_CATALOGS_TRANSACTION_LIST_PAGE); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
return [ |
|
74
|
|
|
'transaction' => $punchoutCatalogTransactionTransfer, |
|
75
|
|
|
]; |
|
76
|
|
|
} |
|
77
|
|
|
} |
|
78
|
|
|
|