Skip to content
Snippets Groups Projects
Commit e4234ee6 authored by Matthias Adrowski's avatar Matthias Adrowski
Browse files

[TASK] Migrate JoblistController

parent fdc53f04
No related branches found
No related tags found
1 merge request!35Feature upgrade to typo3 11
...@@ -146,13 +146,12 @@ class JoblistController extends ActionController { ...@@ -146,13 +146,12 @@ class JoblistController extends ActionController {
* @param array $filters * @param array $filters
* @param int $jobId * @param int $jobId
* @param int $currentPageBrowserPage * @param int $currentPageBrowserPage
* @return void
* @throws \TYPO3\CMS\Core\Context\Exception\AspectNotFoundException * @throws \TYPO3\CMS\Core\Context\Exception\AspectNotFoundException
* @throws \TYPO3\CMS\Core\Error\Http\PageNotFoundException * @throws \TYPO3\CMS\Core\Error\Http\PageNotFoundException
* @throws ImmediateResponseException * @throws ImmediateResponseException
* @throws \TYPO3\CMS\Core\Package\Exception * @throws \TYPO3\CMS\Core\Package\Exception
*/ */
public function indexAction(array $filters = [], int $jobId = NULL, int $currentPageBrowserPage = 0): void { public function indexAction(array $filters = [], int $jobId = NULL, int $currentPageBrowserPage = 0): ?\Psr\Http\Message\ResponseInterface {
if ($filters) { if ($filters) {
$this->view->assign('selectedCountry', $filters['filterCountry']); $this->view->assign('selectedCountry', $filters['filterCountry']);
$this->view->assign('selectedCompany', $filters['filterCompany']); $this->view->assign('selectedCompany', $filters['filterCompany']);
...@@ -239,6 +238,13 @@ class JoblistController extends ActionController { ...@@ -239,6 +238,13 @@ class JoblistController extends ActionController {
$this->view->assign('jobs', $jobs); $this->view->assign('jobs', $jobs);
$this->view->assign('limit', $jobLimit); $this->view->assign('limit', $jobLimit);
$this->view->assign('numberOfPages', $numberOfPages); $this->view->assign('numberOfPages', $numberOfPages);
if (version_compare(\TYPO3\CMS\Core\Utility\VersionNumberUtility::getCurrentTypo3Version(), '11.0.0', '<')) {
return NULL;
}
else {
return $this->htmlResponse();
}
} }
/** /**
...@@ -251,7 +257,7 @@ class JoblistController extends ActionController { ...@@ -251,7 +257,7 @@ class JoblistController extends ActionController {
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\InvalidArgumentNameException * @throws \TYPO3\CMS\Extbase\Mvc\Exception\InvalidArgumentNameException
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException * @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException
*/ */
public function applyFormAction(JobApplication $applyData = NULL, string $error = '', int $jobId = NULL): void { public function applyFormAction(JobApplication $applyData = NULL, string $error = '', int $jobId = NULL): ?\Psr\Http\Message\ResponseInterface {
if ($error !== '') { if ($error !== '') {
$this->view->assign('internalError', $error); $this->view->assign('internalError', $error);
$this->request->setArgument('error', NULL); $this->request->setArgument('error', NULL);
...@@ -348,22 +354,34 @@ class JoblistController extends ActionController { ...@@ -348,22 +354,34 @@ class JoblistController extends ActionController {
$arguments['applyData'] = (string) $arguments['applyData']; $arguments['applyData'] = (string) $arguments['applyData'];
$this->request->setArguments($arguments); $this->request->setArguments($arguments);
} }
if (version_compare(\TYPO3\CMS\Core\Utility\VersionNumberUtility::getCurrentTypo3Version(), '11.0.0', '<')) {
return NULL;
}
else {
return $this->htmlResponse();
}
} }
/** /**
* Pre-apply action setup, configures model-property mapping and handles file upload * Pre-apply action setup, configures model-property mapping and handles file upload
* *
* @return void
* @throws NoSuchArgumentException * @throws NoSuchArgumentException
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException * @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException
*/ */
protected function initializeApplyAction(): void { protected function initializeApplyAction(): ?\Psr\Http\Message\ResponseInterface {
try { try {
$uniqueFolderName = $this->request->getArgument('folderName'); $uniqueFolderName = $this->request->getArgument('folderName');
} catch (NoSuchArgumentException $exception) { } catch (NoSuchArgumentException $exception) {
$exceptionMessage = 'Some file could not be uploaded. Is it too large?'; $exceptionMessage = 'Some file could not be uploaded. Is it too large?';
$this->redirect('applyForm', NULL, NULL, ['error' => $exceptionMessage]);
exit; if (version_compare(\TYPO3\CMS\Core\Utility\VersionNumberUtility::getCurrentTypo3Version(), '11.0.0', '<')) {
$this->redirect('applyForm', NULL, NULL, ['error' => $exceptionMessage]);
return NULL;
}
else {
return $this->redirect('applyForm', NULL, NULL, ['error' => $exceptionMessage]);
}
} }
$propertyMappingConfiguration = $this->arguments->getArgument('applyData')->getPropertyMappingConfiguration(); $propertyMappingConfiguration = $this->arguments->getArgument('applyData')->getPropertyMappingConfiguration();
$propertyMappingConfiguration->forProperty('job')->allowAllProperties(); $propertyMappingConfiguration->forProperty('job')->allowAllProperties();
...@@ -377,6 +395,12 @@ class JoblistController extends ActionController { ...@@ -377,6 +395,12 @@ class JoblistController extends ActionController {
$typeConverter->setTargetUploadFileName($property); $typeConverter->setTargetUploadFileName($property);
$propertyMappingConfiguration->forProperty($property)->setTypeConverter($typeConverter); $propertyMappingConfiguration->forProperty($property)->setTypeConverter($typeConverter);
} }
if (version_compare(\TYPO3\CMS\Core\Utility\VersionNumberUtility::getCurrentTypo3Version(), '11.0.0', '<')) {
return NULL;
}
else {
return $this->htmlResponse();
}
} }
/** /**
...@@ -406,7 +430,7 @@ class JoblistController extends ActionController { ...@@ -406,7 +430,7 @@ class JoblistController extends ActionController {
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\InvalidArgumentNameException * @throws \TYPO3\CMS\Extbase\Mvc\Exception\InvalidArgumentNameException
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException * @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException
*/ */
public function applyAction(JobApplication $applyData): void { public function applyAction(JobApplication $applyData): ?\Psr\Http\Message\ResponseInterface {
$folderName = $this->request->getArgument('folderName'); $folderName = $this->request->getArgument('folderName');
try { try {
...@@ -492,6 +516,13 @@ class JoblistController extends ActionController { ...@@ -492,6 +516,13 @@ class JoblistController extends ActionController {
['applyData' => $applyData, 'error' => $exception->getMessage(), 'jobId' => $jobId] ['applyData' => $applyData, 'error' => $exception->getMessage(), 'jobId' => $jobId]
); );
} }
if (version_compare(\TYPO3\CMS\Core\Utility\VersionNumberUtility::getCurrentTypo3Version(), '11.0.0', '<')) {
return NULL;
}
else {
return $this->htmlResponse();
}
} }
/** /**
...@@ -500,7 +531,7 @@ class JoblistController extends ActionController { ...@@ -500,7 +531,7 @@ class JoblistController extends ActionController {
* @param int $rootPageId * @param int $rootPageId
* @throws \TYPO3\CMS\Core\Context\Exception\AspectNotFoundException * @throws \TYPO3\CMS\Core\Context\Exception\AspectNotFoundException
*/ */
protected function assignFilterValues($rootPageId): void { protected function assignFilterValues($rootPageId): ?\Psr\Http\Message\ResponseInterface {
$countries = $this->companyRepository->getAllCountries($rootPageId); $countries = $this->companyRepository->getAllCountries($rootPageId);
$this->view->assign('countries', $countries); $this->view->assign('countries', $countries);
...@@ -515,6 +546,13 @@ class JoblistController extends ActionController { ...@@ -515,6 +546,13 @@ class JoblistController extends ActionController {
$experienceLevels = $this->experienceLevelRepository->findAll(); $experienceLevels = $this->experienceLevelRepository->findAll();
$this->view->assign('experienceLevels', $experienceLevels); $this->view->assign('experienceLevels', $experienceLevels);
if (version_compare(\TYPO3\CMS\Core\Utility\VersionNumberUtility::getCurrentTypo3Version(), '11.0.0', '<')) {
return NULL;
}
else {
return $this->htmlResponse();
}
} }
/** /**
...@@ -667,4 +705,16 @@ class JoblistController extends ActionController { ...@@ -667,4 +705,16 @@ class JoblistController extends ActionController {
parent::errorAction(); parent::errorAction();
} }
/**
* Build Typo3 11 Response
* @param string|NULL $html
* @return \Psr\Http\Message\ResponseInterface
*/
protected function htmlResponse(string $html = null): \Psr\Http\Message\ResponseInterface
{
return $this->responseFactory->createResponse()
->withHeader('Content-Type', 'text/html; charset=utf-8')
->withBody($this->streamFactory->createStream($html ?? $this->view->render()));
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment