Skip to content

Commit 28bb59e

Browse files
committedMar 21, 2024·
More changes related to TYPO3 v12
1 parent f3bd8cf commit 28bb59e

File tree

12 files changed

+58
-75
lines changed

12 files changed

+58
-75
lines changed
 

‎Classes/Command/ImportCommandController.php

+4-5
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,17 @@ class ImportCommandController extends Command
2626
* ImportCommandController constructor.
2727
* @param string|null $name
2828
*/
29-
public function __construct(string $name = null)
29+
public function __construct(protected Manager $manager)
3030
{
31-
parent::__construct($name);
31+
parent::__construct(null);
3232
}
3333

3434
/**
3535
* @param InputInterface $input
3636
* @param OutputInterface $output
3737
* @return int
3838
*/
39-
protected function execute(InputInterface $input, OutputInterface $output)
39+
protected function execute(InputInterface $input, OutputInterface $output):int
4040
{
4141
$this->initializeServiceManagerCommand();
4242

@@ -60,10 +60,9 @@ public function initializeServiceManagerCommand($mail = null)
6060
);
6161
$this->addFlashMessage($message);
6262

63-
$manager = GeneralUtility::makeInstance(Manager::class);
6463
try {
6564
// let the manager run the imports now
66-
$manager->runImports();
65+
$this->manager->runImports();
6766
} catch (\Exception $e) {
6867
$message = GeneralUtility::makeInstance(
6968
FlashMessage::class,

‎Classes/Controller/ImportrController.php

+37-12
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,14 @@
1111
use HDNET\Importr\Service\ImportServiceInterface;
1212
use HDNET\Importr\Service\Manager;
1313
use Psr\Http\Message\ResponseInterface;
14+
use TYPO3\CMS\Backend\Template\ModuleTemplate;
15+
use TYPO3\CMS\Backend\Template\ModuleTemplateFactory;
1416
use TYPO3\CMS\Core\Messaging\FlashMessage;
1517
use TYPO3\CMS\Core\Messaging\FlashMessageService;
1618
use TYPO3\CMS\Core\Resource\ResourceFactory;
1719
use TYPO3\CMS\Core\Utility\GeneralUtility;
1820
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
21+
use TYPO3\CMS\Extbase\Utility\DebuggerUtility;
1922

2023
/**
2124
* Description of ImportrController
@@ -54,7 +57,8 @@ public function __construct(
5457
StrategyRepository $strategyRepository,
5558
ImportRepository $importRepository,
5659
Manager $importManager,
57-
ImportServiceInterface $importService
60+
ImportServiceInterface $importService,
61+
protected ModuleTemplateFactory $moduleTemplateFactory
5862
) {
5963
$this->resourceFactory = $resourceFactory;
6064
$this->strategyRepository = $strategyRepository;
@@ -65,6 +69,7 @@ public function __construct(
6569

6670
public function indexAction():ResponseInterface
6771
{
72+
$viewVariables = [];
6873
$combinedIdentifier = GeneralUtility::_GP('id');
6974
if (isset($combinedIdentifier) && \is_string($combinedIdentifier)) {
7075
$folder = $this->resourceFactory->getFolderObjectFromCombinedIdentifier($combinedIdentifier);
@@ -73,11 +78,13 @@ public function indexAction():ResponseInterface
7378
$files[$file->getStorage()
7479
->getUid() . ':' . $file->getIdentifier()] = $file->getName();
7580
}
76-
$this->view->assign('folder', $files);
81+
$viewVariables['folder'] = $files;
7782
}
78-
$this->view->assign('imports', $this->importRepository->findUserQueue());
83+
$viewVariables['imports'] = $this->importRepository->findUserQueue();
7984

80-
return $this->htmlResponse($this->view->render());
85+
return $this->createModuleTemplate()
86+
->assignMultiple($viewVariables)
87+
->renderResponse('Index');
8188
}
8289

8390
/**
@@ -86,9 +93,13 @@ public function indexAction():ResponseInterface
8693
public function importAction($identifier):ResponseInterface
8794
{
8895
$file = $this->resourceFactory->getObjectFromCombinedIdentifier($identifier);
89-
$this->view->assign('file', $file);
90-
$this->view->assign('strategies', $this->strategyRepository->findAllUser());
91-
return $this->htmlResponse($this->view->render());
96+
$viewVariables = [
97+
'file' => $file,
98+
'strategies' => $this->strategyRepository->findAllUser(),
99+
];
100+
return $this->createModuleTemplate()
101+
->assignMultiple($viewVariables)
102+
->renderResponse('Import');
92103
}
93104

94105
/**
@@ -98,12 +109,19 @@ public function importAction($identifier):ResponseInterface
98109
public function previewAction($identifier, Strategy $strategy):ResponseInterface
99110
{
100111
$file = $this->resourceFactory->getObjectFromCombinedIdentifier($identifier);
101-
$this->view->assign('filepath', $file->getPublicUrl());
102-
$this->view->assign('strategy', $strategy);
103112

104-
$previewData = $this->importManager->getPreview($strategy, $file->getPublicUrl());
105-
$this->view->assign('preview', $previewData);
106-
return $this->htmlResponse($this->view->render());
113+
$filePath = $file->getForLocalProcessing();
114+
// @todo check path (absolute)
115+
$previewData = $this->importManager->getPreview($strategy, $filePath);
116+
117+
return $this->createModuleTemplate()
118+
->assignMultiple([
119+
// @todo better the file ID
120+
'filepath' => $filePath,
121+
'strategy' => $strategy,
122+
'preview' => $previewData,
123+
])
124+
->renderResponse('Preview');
107125
}
108126

109127
/**
@@ -140,4 +158,11 @@ public function resetAction(Import $import):ResponseInterface
140158
$this->importRepository->update($import);
141159
return $this->redirect('index');
142160
}
161+
162+
protected function createModuleTemplate(): ModuleTemplate
163+
{
164+
return $this->moduleTemplateFactory->create($this->request)
165+
->setFlashMessageQueue($this->getFlashMessageQueue())
166+
->setModuleClass('tx-impotr');
167+
}
143168
}

‎Classes/Domain/Model/Strategy.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use TYPO3\CMS\Core\Resource\FileInterface;
1111
use TYPO3\CMS\Core\Utility\GeneralUtility;
1212
use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
13+
use TYPO3\CMS\Extbase\Utility\DebuggerUtility;
1314

1415
/**
1516
* Documentation for configuration
@@ -74,7 +75,7 @@ public function getTitle()
7475
*/
7576
public function getRawConfiguration()
7677
{
77-
if ($config = GeneralUtility::getUrl($this->getRealFilePath($this->configurationFile))) {
78+
if ($this->configurationFile && $config = GeneralUtility::getUrl($this->getRealFilePath($this->configurationFile))) {
7879
return $config;
7980
}
8081

@@ -96,7 +97,7 @@ public function getConfiguration()
9697
*/
9798
public function getRawResources()
9899
{
99-
if ($resources = GeneralUtility::getUrl($this->getRealFilePath($this->resourcesFile))) {
100+
if ($this->resourcesFile && $resources = GeneralUtility::getUrl($this->getRealFilePath($this->resourcesFile))) {
100101
return $resources;
101102
}
102103

@@ -116,7 +117,7 @@ public function getResources()
116117
*/
117118
public function getRawTargets()
118119
{
119-
if ($targets = GeneralUtility::getUrl($this->getRealFilePath($this->targetsFile))) {
120+
if ($this->targetsFile && $targets = GeneralUtility::getUrl($this->getRealFilePath($this->targetsFile))) {
120121
return $targets;
121122
}
122123

‎Classes/Processor/Target.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,6 @@ protected function emitEntrySignal($name, array $configuration, $entry)
6666
# [$configuration, $entry]
6767
#);
6868

69-
return $result[1];
69+
return $entry;
7070
}
7171
}

‎Classes/Service/Resources/Csv.php

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
use HDNET\Importr\Domain\Model\Strategy;
77
use TYPO3\CMS\Core\Utility\GeneralUtility;
8+
use TYPO3\CMS\Extbase\Utility\DebuggerUtility;
89

910
/**
1011
* Description of Csv

‎Configuration/TCA/tx_importr_domain_model_import.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
if (!defined('TYPO3_MODE')) {
3+
if (!defined('TYPO3')) {
44
die('Access denied.');
55
}
66

‎Configuration/TCA/tx_importr_domain_model_strategy.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
if (!defined('TYPO3_MODE')) {
3+
if (!defined('TYPO3')) {
44
die('Access denied.');
55
}
66

‎Resources/Private/Layouts/Backend.html

-35
This file was deleted.

‎Resources/Private/Templates/Importr/Import.html

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
<f:layout name="Backend"/>
2-
3-
<f:section name="IconButtons">
4-
<a href="{f:uri.action(action:'index')}" title="Cancel Import" class="btn btn-default btn-sm">
5-
<core:icon identifier="actions-move-left"/>
6-
</a>
7-
</f:section>
1+
<f:layout name="Module"/>
82

93
<f:section name="Content">
4+
<a href="{f:uri.action(action:'index')}" title="Cancel Import" class="btn btn-default btn-sm">
5+
<core:icon identifier="actions-move-left"/>
6+
</a>
107
<h1>
118
<f:translate key="LLL:EXT:importr/Resources/Private/Language/locallang.xlf:importr"/>
129
</h1>

‎Resources/Private/Templates/Importr/Index.html

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
<f:layout name="Backend"/>
2-
3-
<f:section name="IconButtons">
4-
5-
</f:section>
1+
<f:layout name="Module"/>
62

73
<f:section name="Content">
84
<h1>

‎Resources/Private/Templates/Importr/Preview.html

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
{namespace importr=HDNET\Importr\ViewHelpers}
2-
<f:layout name="Backend" />
2+
<f:layout name="Module"/>
3+
4+
<f:section name="Content">
35

4-
<f:section name="IconButtons">
56
<a href="{f:uri.action(action:'index')}" title="Cancel Import" class="btn btn-default btn-sm">
67
<core:icon identifier="actions-move-left"/>
78
</a>
8-
</f:section>
99

10-
<f:section name="Content">
1110
<h1>
1211
<f:translate key="LLL:EXT:importr/Resources/Private/Language/locallang.xlf:importr" />
1312
</h1>

‎ext_localconf.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
if (!defined('TYPO3_MODE')) {
3+
if (!defined('TYPO3')) {
44
die('Access denied.');
55
}
66

0 commit comments

Comments
 (0)
Please sign in to comment.