Projekt

Obecné

Profil

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

    
3
namespace App\FrontModule\Presenters;
4

    
5

    
6

    
7
use App\FrontModule\Components\ITransliterationSearchFormFactory;
8
use App\FrontModule\Components\ITransliterationSearchResultListFactory;
9
use App\Model\Repository\LineRepository;
10
use App\Model\Repository\LitReferenceRepository;
11
use App\Model\Repository\RevHistoryRepository;
12
use App\Model\Repository\TransliterationRepository;
13
use App\Model\TransliterationSearchModel;
14
use Nette\Application\UI\Presenter;
15

    
16
class TransliterationPresenter extends Presenter
17
{
18
    /** @var ITransliterationSearchFormFactory */
19
    private $transliterationSearchFormFactory;
20

    
21
    /** @var TransliterationRepository */
22
    private $transliterationRepository;
23

    
24
    /** @var TransliterationSearchModel */
25
    private $transliterationSearchModel;
26

    
27
    /** @var LitReferenceRepository */
28
    private $litReferenceRepository;
29

    
30
    /** @var RevHistoryRepository */
31
    private $revHistoryRepository;
32

    
33
    /** @var LineRepository */
34
    private $lineRepository;
35

    
36
    /** @var ITransliterationSearchResultListFactory */
37
    private $transliterationSearchResultListFactory;
38

    
39
    public function __construct(
40
        ITransliterationSearchFormFactory $transliterationSearchFormFactory,
41
        TransliterationRepository $transliterationRepository,
42
        TransliterationSearchModel $transliterationSearchModel,
43
        LitReferenceRepository $litReferenceRepository,
44
        RevHistoryRepository $revHistoryRepository,
45
        LineRepository $lineRepository,
46
        ITransliterationSearchResultListFactory $transliterationSearchResultListFactory
47
    )
48
    {
49
        parent::__construct();
50

    
51
        $this->transliterationSearchFormFactory = $transliterationSearchFormFactory;
52
        $this->transliterationRepository = $transliterationRepository;
53
        $this->transliterationSearchModel = $transliterationSearchModel;
54
        $this->litReferenceRepository = $litReferenceRepository;
55
        $this->revHistoryRepository = $revHistoryRepository;
56
        $this->lineRepository = $lineRepository;
57
        $this->transliterationSearchResultListFactory = $transliterationSearchResultListFactory;
58
    }
59

    
60
    public function actionView($id)
61
    {
62
        $transliteration = $this->transliterationRepository->getTransliterationDetail($id);
63
        if(!$transliteration)
64
        {
65
            $this->presenter->flashMessage('Transliteration not found');
66
            $this->redirect('Transliteration:search');
67
        }
68
        $lines = $this->lineRepository->getAllLinesForTransliteration($id);
69
        $lineArray = [];
70
        foreach ($lines as $line)
71
        {
72
            $lineArray[$line->object_type][$line->surface_type][] = array('transliteration' => $line->transliteration, 'line_number' => $line->line_number);
73
        }
74

    
75
        $this->template->transliteration = $transliteration;
76
        $this->template->litReferences = $this->litReferenceRepository->findBy([LitReferenceRepository::COLUMN_TRANSLITERATION_ID => $id]);
77
        $this->template->revisionHistory = $this->revHistoryRepository->findBy([RevHistoryRepository::COLUMN_TRANSLITERATION_ID => $id]);
78
        $this->template->lineArray = $lineArray;
79
    }
80

    
81
    public function createComponentTransliterationSearchForm()
82
    {
83
        return $this->transliterationSearchFormFactory->create();
84
    }
85

    
86
    public function createComponentTransliterationSearchResultList()
87
    {
88
        return $this->transliterationSearchResultListFactory->create();
89
    }
90
}
(4-4/4)