Revize 2f604f1a
Přidáno uživatelem Petr Lukašík před téměř 6 roky(ů)
app/AdminModule/presenters/TransportPresenter.php | ||
---|---|---|
8 | 8 |
use App\Model\Facade\TransportFacade; |
9 | 9 |
use App\Model\Repository\ObjectTypeRepository; |
10 | 10 |
use App\Model\Repository\SurfaceTypeRepository; |
11 |
use App\Model\TransportModel; |
|
11 | 12 |
use App\Utils\TextParser; |
12 | 13 |
|
13 | 14 |
class TransportPresenter extends BaseUserPresenter |
... | ... | |
27 | 28 |
/** @var TransportFacade */ |
28 | 29 |
private $transportFacade; |
29 | 30 |
|
31 |
/** @var TransportModel */ |
|
32 |
private $transportModel; |
|
33 |
|
|
30 | 34 |
public function __construct( |
31 | 35 |
IImportFormFactory $importFormFactory, |
32 | 36 |
IExportFormFactory $exportFormFactory, |
33 | 37 |
SurfaceTypeRepository $surfaceTypeRepository, |
34 | 38 |
ObjectTypeRepository $objectTypeRepository, |
35 |
TransportFacade $transportFacade |
|
39 |
TransportFacade $transportFacade, |
|
40 |
TransportModel $transportModel |
|
36 | 41 |
) |
37 | 42 |
{ |
38 | 43 |
parent::__construct(); |
... | ... | |
41 | 46 |
$this->surfaceTypeRepository = $surfaceTypeRepository; |
42 | 47 |
$this->objectTypeRepository = $objectTypeRepository; |
43 | 48 |
$this->transportFacade = $transportFacade; |
49 |
$this->transportModel = $transportModel; |
|
44 | 50 |
} |
45 | 51 |
|
46 | 52 |
/** |
... | ... | |
53 | 59 |
$surfaceTypes = $this->surfaceTypeRepository->fetchSurfaceTypes(); |
54 | 60 |
$parser->setTypes($objectTypes, $surfaceTypes); |
55 | 61 |
|
56 |
// Potřebuju to jako persistentní data do další akce presenteru |
|
57 |
$_SESSION['parsedText'] = $parser->parseText(); |
|
62 |
$this->transportModel->setParsedText($parser->parseText()); |
|
58 | 63 |
|
59 | 64 |
$this->template->fileName = $parser->getTextFile()->getName(); |
60 |
$this->template->parsedFile = $_SESSION['parsedText'];
|
|
65 |
$this->template->parsedFile = $this->transportModel->getParsedText();
|
|
61 | 66 |
$this->template->transliterationNum = $this->countTransliterations(); |
62 | 67 |
$this->template->surfaces = $surfaceTypes; |
63 | 68 |
} |
... | ... | |
67 | 72 |
*/ |
68 | 73 |
public function actionConfirmPreview() |
69 | 74 |
{ |
70 |
$result = $this->transportFacade->saveImportedData($_SESSION['parsedText']); |
|
71 |
$_SESSION['parsedText'] = null; |
|
75 |
$result = $this->transportFacade->saveImportedData($this->transportModel->getParsedText()); |
|
72 | 76 |
|
73 | 77 |
if ($result) { |
74 | 78 |
$this->presenter->flashMessage('All data were imported successfully.', EFlashMessage::SUCCESS); |
app/config/model.neon | ||
---|---|---|
23 | 23 |
- App\Model\Facade\TransportFacade |
24 | 24 |
|
25 | 25 |
#Sessions |
26 |
- App\Model\TransliterationSearchModel |
|
26 |
- App\Model\TransliterationSearchModel |
|
27 |
- App\Model\TransportModel |
app/model/TransportModel.php | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
|
|
4 |
namespace App\Model; |
|
5 |
|
|
6 |
|
|
7 |
use Nette\Http\Session; |
|
8 |
use Nette\Http\SessionSection; |
|
9 |
|
|
10 |
class TransportModel |
|
11 |
{ |
|
12 |
const SECTION_NAME = "Transport"; |
|
13 |
const SECTION_EXPIRATION = 0; |
|
14 |
|
|
15 |
/** @var SessionSection */ |
|
16 |
private $section; |
|
17 |
|
|
18 |
public function __construct(Session $session) |
|
19 |
{ |
|
20 |
$this->section = $session->getSection(self::SECTION_NAME); |
|
21 |
$this->section->setExpiration(self::SECTION_EXPIRATION); |
|
22 |
} |
|
23 |
|
|
24 |
/** |
|
25 |
* @return SessionSection |
|
26 |
*/ |
|
27 |
public function getTransportSection(){ |
|
28 |
return $this->section; |
|
29 |
} |
|
30 |
|
|
31 |
/** |
|
32 |
* @param array $parsedText |
|
33 |
*/ |
|
34 |
public function setParsedText(array $parsedText){ |
|
35 |
$this->section->parsedText = $parsedText; |
|
36 |
} |
|
37 |
|
|
38 |
/** |
|
39 |
* @return array |
|
40 |
*/ |
|
41 |
public function getParsedText(){ |
|
42 |
return $this->section->parsedText; |
|
43 |
} |
|
44 |
} |
Také k dispozici: Unified diff
Re #7510 úprava na využití struktury nette session