1 |
93413904
|
Jan Šedivý
|
<?php
|
2 |
|
|
|
3 |
|
|
namespace App\AdminModule\Presenters;
|
4 |
|
|
|
5 |
|
|
|
6 |
8b71ca4d
|
Jan Šedivý
|
use App\AdminModule\Components\ISurfaceTypeEditFormFactory;
|
7 |
93413904
|
Jan Šedivý
|
use App\AdminModule\Components\ISurfaceTypeGridFactory;
|
8 |
db8e40be
|
Jan Šedivý
|
use App\Enum\EFlashMessage;
|
9 |
|
|
use App\Model\Repository\SurfaceTypeRepository;
|
10 |
93413904
|
Jan Šedivý
|
|
11 |
601eec74
|
Jan Šedivý
|
class SurfacePresenter extends BaseUserPresenter
|
12 |
93413904
|
Jan Šedivý
|
{
|
13 |
|
|
/** @var ISurfaceTypeGridFactory */
|
14 |
|
|
private $surfaceTypeGridFactory;
|
15 |
|
|
|
16 |
8b71ca4d
|
Jan Šedivý
|
/** @var ISurfaceTypeEditFormFactory */
|
17 |
|
|
private $surfaceTypeEditFormFactory;
|
18 |
|
|
|
19 |
db8e40be
|
Jan Šedivý
|
/** @var SurfaceTypeRepository */
|
20 |
|
|
private $surfaceTypeRepository;
|
21 |
|
|
|
22 |
93413904
|
Jan Šedivý
|
private $typeId;
|
23 |
|
|
|
24 |
|
|
/**
|
25 |
|
|
* SurfacePresenter constructor.
|
26 |
|
|
* @param ISurfaceTypeGridFactory $surfaceTypeGridFactory
|
27 |
8b71ca4d
|
Jan Šedivý
|
* @param ISurfaceTypeEditFormFactory $surfaceTypeEditFormFactory
|
28 |
db8e40be
|
Jan Šedivý
|
* @param SurfaceTypeRepository $surfaceTypeRepository
|
29 |
93413904
|
Jan Šedivý
|
*/
|
30 |
8b71ca4d
|
Jan Šedivý
|
public function __construct(
|
31 |
|
|
ISurfaceTypeGridFactory $surfaceTypeGridFactory,
|
32 |
db8e40be
|
Jan Šedivý
|
ISurfaceTypeEditFormFactory $surfaceTypeEditFormFactory,
|
33 |
|
|
SurfaceTypeRepository $surfaceTypeRepository
|
34 |
8b71ca4d
|
Jan Šedivý
|
)
|
35 |
93413904
|
Jan Šedivý
|
{
|
36 |
|
|
parent::__construct();
|
37 |
|
|
|
38 |
|
|
$this->surfaceTypeGridFactory = $surfaceTypeGridFactory;
|
39 |
8b71ca4d
|
Jan Šedivý
|
$this->surfaceTypeEditFormFactory = $surfaceTypeEditFormFactory;
|
40 |
db8e40be
|
Jan Šedivý
|
$this->surfaceTypeRepository = $surfaceTypeRepository;
|
41 |
93413904
|
Jan Šedivý
|
}
|
42 |
|
|
|
43 |
|
|
public function actionAddType()
|
44 |
|
|
{
|
45 |
|
|
|
46 |
|
|
}
|
47 |
|
|
|
48 |
8b71ca4d
|
Jan Šedivý
|
public function actionEditType(int $id)
|
49 |
93413904
|
Jan Šedivý
|
{
|
50 |
06d4f041
|
Jan Šedivý
|
if(!$this->surfaceTypeRepository->findRow($id))
|
51 |
|
|
{
|
52 |
|
|
$this->flashMessage('Surface type was not found.', EFlashMessage::ERROR);
|
53 |
|
|
$this->redirect('Surface:');
|
54 |
|
|
}
|
55 |
|
|
|
56 |
8b71ca4d
|
Jan Šedivý
|
$this->typeId = $id;
|
57 |
db8e40be
|
Jan Šedivý
|
$this->template->id = $id;
|
58 |
93413904
|
Jan Šedivý
|
}
|
59 |
|
|
|
60 |
4ca0744d
|
Filip Jani
|
public function handleDeleteType(int $id)
|
61 |
|
|
{
|
62 |
|
|
if($this->isAjax())
|
63 |
|
|
{
|
64 |
|
|
$this->surfaceTypeRepository->delete($id);
|
65 |
|
|
$this['surfaceTypeGrid']->reload();
|
66 |
|
|
}
|
67 |
|
|
}
|
68 |
|
|
|
69 |
8b71ca4d
|
Jan Šedivý
|
public function actionDeleteType(int $id)
|
70 |
93413904
|
Jan Šedivý
|
{
|
71 |
db8e40be
|
Jan Šedivý
|
if($this->surfaceTypeRepository->delete($id))
|
72 |
|
|
{
|
73 |
|
|
$this->flashMessage('Surface type was deleted.', EFlashMessage::SUCCESS);
|
74 |
|
|
}
|
75 |
|
|
else
|
76 |
|
|
{
|
77 |
|
|
$this->flashMessage('Surface type was not found.', EFlashMessage::ERROR);
|
78 |
|
|
}
|
79 |
|
|
$this->redirect('Surface:');
|
80 |
93413904
|
Jan Šedivý
|
}
|
81 |
|
|
|
82 |
|
|
public function createComponentSurfaceTypeGrid()
|
83 |
|
|
{
|
84 |
|
|
return $this->surfaceTypeGridFactory->create();
|
85 |
|
|
}
|
86 |
8b71ca4d
|
Jan Šedivý
|
|
87 |
|
|
public function createComponentSurfaceTypeEditForm()
|
88 |
|
|
{
|
89 |
|
|
return $this->surfaceTypeEditFormFactory->create($this->typeId);
|
90 |
|
|
}
|
91 |
93413904
|
Jan Šedivý
|
}
|