Projekt

Obecné

Profil

Stáhnout (1.57 KB) Statistiky
| Větev: | Tag: | Revize:
1
<?php
2

    
3

    
4
namespace App\AdminModule\Presenters;
5

    
6
use App\AdminModule\Components\IMuseumEditFormFactory;
7
use App\AdminModule\Components\IMuseumGridFactory;
8
use App\Model\Repository\MuseumRepository;
9

    
10
class MuseumPresenter extends BaseUserPresenter
11
{
12
    /**
13
     * @var IMuseumGridFactory
14
     */
15
    private $museumGridFactory;
16
    /**
17
     * @var IMuseumEditFormFactory
18
     */
19
    private $museumEditFormFactory;
20
    /**
21
     * @var MuseumRepository
22
     */
23
    private $museumRepository;
24

    
25
    public function __construct(IMuseumGridFactory $museumGridFactory,
26
                                IMuseumEditFormFactory $museumEditFormFactory,
27
                                MuseumRepository $museumRepository
28
    )
29
    {
30
        parent::__construct();
31

    
32
        $this->museumGridFactory = $museumGridFactory;
33
        $this->museumEditFormFactory = $museumEditFormFactory;
34
        $this->museumRepository = $museumRepository;
35
    }
36

    
37
    public function actionEdit(int $id)
38
    {
39
        $this['museumEditForm']->setMuseum($id);
40
    }
41

    
42
    /**
43
     * Handle používaný v MuseumGrid pro smazání muzea
44
     *
45
     * @param int $id : ID mazaného muzea
46
     */
47
    public function handleDeleteMuseum(int $id)
48
    {
49
        if ($this->isAjax())
50
        {
51
            $this->museumRepository->findRow($id)->delete();
52
            $this['museumGrid']->reload();
53
        }
54
    }
55

    
56
    public function createComponentMuseumGrid()
57
    {
58
        return $this->museumGridFactory->create();
59
    }
60

    
61
    public function createComponentMuseumEditForm()
62
    {
63
        return $this->museumEditFormFactory->create();
64
    }
65
}
(6-6/11)