Revize 2d082bc2
Přidáno uživatelem Petr Lukašík před téměř 6 roky(ů)
app/AdminModule/presenters/TransportPresenter.php | ||
---|---|---|
4 | 4 | |
5 | 5 |
use App\AdminModule\Components\IExportFormFactory; |
6 | 6 |
use App\AdminModule\Components\IImportFormFactory; |
7 |
use App\Model\Repository\ObjectTypeRepository; |
|
8 |
use App\Model\Repository\SurfaceTypeRepository; |
|
9 |
use App\Utils\TextParser; |
|
7 | 10 | |
8 | 11 |
class TransportPresenter extends BaseUserPresenter |
9 | 12 |
{ |
... | ... | |
13 | 16 |
/** @var IExportFormFactory */ |
14 | 17 |
private $exportFormFactory; |
15 | 18 | |
19 |
/** @var SurfaceTypeRepository */ |
|
20 |
private $surfaceTypeRepository; |
|
21 | ||
22 |
/** @var ObjectTypeRepository */ |
|
23 |
private $objectTypeRepository; |
|
24 | ||
16 | 25 |
public function __construct( |
17 | 26 |
IImportFormFactory $importFormFactory, |
18 |
IExportFormFactory $exportFormFactory |
|
27 |
IExportFormFactory $exportFormFactory, |
|
28 |
SurfaceTypeRepository $surfaceTypeRepository, |
|
29 |
ObjectTypeRepository $objectTypeRepository |
|
19 | 30 |
) |
20 | 31 |
{ |
21 | 32 |
parent::__construct(); |
22 | 33 |
$this->importFormFactory = $importFormFactory; |
23 | 34 |
$this->exportFormFactory = $exportFormFactory; |
35 |
$this->surfaceTypeRepository = $surfaceTypeRepository; |
|
36 |
$this->objectTypeRepository = $objectTypeRepository; |
|
37 |
} |
|
38 | ||
39 |
public function actionPreviewImport(TextParser $parser){ |
|
40 |
$objectTypes = $this->objectTypeRepository->fetchObjectTypes(); |
|
41 |
$surfaceTypes = $this->surfaceTypeRepository->fetchSurfaceTypes(); |
|
42 |
$parser->setTypes($objectTypes, $surfaceTypes); |
|
43 | ||
44 |
$this->template->fileName = $parser->textFile->getName(); |
|
45 |
$this->template->parsedFile = $parser->parseText(); |
|
46 |
$this->template->transliterationNum = $this->countTransliterations(); |
|
47 |
$this->template->surfaces = $surfaceTypes; |
|
48 |
} |
|
49 | ||
50 |
public function countTransliterations(){ |
|
51 |
$num=0; |
|
52 |
foreach ($this->template->parsedFile as $book){ |
|
53 |
$num += count($book); |
|
54 |
} |
|
55 |
return $num; |
|
24 | 56 |
} |
25 | 57 | |
26 | 58 |
public function createComponentImportForm() |
Také k dispozici: Unified diff
Re #7510 Úprava vzhledu, implementace parsování souboru a funkcionalita importu, preview