Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 80b17f46

Přidáno uživatelem Jan Šedivý před téměř 6 roky(ů)

Re #7335 Formulář pro správu typu objektů v administraci

Zobrazit rozdíly:

app/AdminModule/presenters/ObjectPresenter.php
3 3
namespace App\AdminModule\Presenters;
4 4

  
5 5

  
6
use App\AdminModule\Components\IObjectTypeEditFormFactory;
6 7
use App\AdminModule\Components\IObjectTypeGridFactory;
8
use App\Enum\EFlashMessage;
7 9
use App\Model\Repository\ObjectTypeRepository;
8 10

  
9 11
class ObjectPresenter extends BaseUserPresenter
......
14 16
    /** @var IObjectTypeGridFactory */
15 17
    private $objectTypeGridFactory;
16 18

  
19
    /** @var IObjectTypeEditFormFactory */
20
    private $objectTypeEditFormFactory;
21

  
22
    private $typeId;
23

  
17 24
    /**
18 25
     * ObjectPresenter constructor.
19 26
     * @param ObjectTypeRepository $objectTypeRepository
27
     * @param IObjectTypeGridFactory $objectTypeGridFactory
28
     * @param IObjectTypeEditFormFactory $objectTypeEditFormFactory
20 29
     */
21 30
    public function __construct(
22 31
        ObjectTypeRepository $objectTypeRepository,
23
        IObjectTypeGridFactory $objectTypeGridFactory
32
        IObjectTypeGridFactory $objectTypeGridFactory,
33
        IObjectTypeEditFormFactory $objectTypeEditFormFactory
24 34
    )
25 35
    {
26 36
        $this->objectTypeRepository = $objectTypeRepository;
27 37
        $this->objectTypeGridFactory = $objectTypeGridFactory;
38
        $this->objectTypeEditFormFactory = $objectTypeEditFormFactory;
28 39

  
29 40
        parent::__construct();
30 41
    }
......
36 47

  
37 48
    public function actionEditType(int $id)
38 49
    {
50
        if(!$this->objectTypeRepository->findRow($id))
51
        {
52
            $this->flashMessage('Object type was not found.', EFlashMessage::ERROR);
53
            $this->redirect('Object:');
54
        }
39 55

  
56
        $this->typeId = $id;
57
        $this->template->id = $id;
40 58
    }
41 59

  
42 60
    public function actionDeleteType(int $id)
43 61
    {
44

  
62
        if($this->objectTypeRepository->delete($id))
63
        {
64
            $this->flashMessage('Object type was deleted.', EFlashMessage::SUCCESS);
65
        }
66
        else
67
        {
68
            $this->flashMessage('Object type was not found.', EFlashMessage::ERROR);
69
        }
70
        $this->redirect('Object:');
45 71
    }
46 72

  
47 73
    public function createComponentObjectTypeGrid()
......
49 75
        return $this->objectTypeGridFactory->create();
50 76
    }
51 77

  
78
    public function createComponentObjectTypeEditForm()
79
    {
80
        return $this->objectTypeEditFormFactory->create($this->typeId);
81
    }
52 82
}

Také k dispozici: Unified diff