diff --git a/Classes/Controller/JoblistController.php b/Classes/Controller/JoblistController.php index e4e978e74e0e8dfd7d81844d8b74225afe2a60cd..8a9181eef49d0335a15d5e35cb2e4d30e186ea20 100644 --- a/Classes/Controller/JoblistController.php +++ b/Classes/Controller/JoblistController.php @@ -28,6 +28,7 @@ namespace SGalinski\SgJobs\Controller; use SGalinski\SgJobs\Domain\Model\JobApplication; use SGalinski\SgMail\Service\MailTemplateService; +use TYPO3\CMS\Core\Messaging\FlashMessage; use TYPO3\CMS\Core\Resource\DuplicationBehavior; use TYPO3\CMS\Core\Resource\ResourceFactory; use TYPO3\CMS\Core\Utility\File\ExtendedFileUtility; @@ -35,7 +36,6 @@ use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface; use TYPO3\CMS\Extbase\Mvc\Controller\ActionController; use TYPO3\CMS\Extbase\Object\ObjectManager; -use TYPO3\CMS\Extbase\Utility\DebuggerUtility; /** * The joblist plugin controller @@ -68,7 +68,6 @@ class JoblistController extends ActionController { $this->assignFilterValues($storagePid); $this->view->assign('recordPageId', $storagePid); - // pagination logic $jobLimit = (int) $this->settings['jobLimit']; $offset = 0; @@ -117,6 +116,9 @@ class JoblistController extends ActionController { * Saves the application send by the applyFormAction * * @param JobApplication $applyData + * @throws \TYPO3\CMS\Extbase\Mvc\Exception\UnsupportedRequestTypeException + * @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException + * @throws \InvalidArgumentException */ public function applyAction(JobApplication $applyData) { try { @@ -147,7 +149,8 @@ class JoblistController extends ActionController { } catch (\Exception $exception) { // possible errors, because of wrong mails (maybe log that somewhere? Does this makes sense?) - // @TODO handle the exception, possibley redirect to form with error message + GeneralUtility::makeInstance(FlashMessage::class, $exception->getMessage()); + $this->redirect('applyFormAction'); } } @@ -155,6 +158,9 @@ class JoblistController extends ActionController { * Pre-apply action setup, configures model-property mapping and handles file upload * * @return void + * @throws \TYPO3\CMS\Extbase\Mvc\Exception\UnsupportedRequestTypeException + * @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException + * @throws \InvalidArgumentException * @throws \TYPO3\CMS\Extbase\Mvc\Exception\InvalidArgumentNameException * @throws \TYPO3\CMS\Extbase\Mvc\Exception\NoSuchArgumentException * @throws \Exception @@ -170,9 +176,10 @@ class JoblistController extends ActionController { $this->handleFileUpload('coverLetter', $uniqueFolderName); $this->handleFileUpload('cv', $uniqueFolderName); $this->handleFileUpload('certificates', $uniqueFolderName); - } catch (\Exception $e) { + } catch (\Exception $exception) { // possible errors, because of wrong mails - // @TODO output them in some way? + GeneralUtility::makeInstance(FlashMessage::class, $exception->getMessage()); + $this->redirect('applyFormAction'); } $propertyMappingConfiguration = $this->arguments->getArgument('applyData')->getPropertyMappingConfiguration(); $propertyMappingConfiguration->forProperty('coverLetter')->allowAllProperties(); @@ -317,6 +324,9 @@ class JoblistController extends ActionController { * @param JobApplication $data * @param string $filePath * @param array $fileNames + * @throws \TYPO3\CMS\Extbase\Mvc\Exception\UnsupportedRequestTypeException + * @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException + * @throws \InvalidArgumentException * @throws \RuntimeException */ private function writeApplicationFile(JobApplication $data, $filePath, $fileNames) { @@ -353,7 +363,8 @@ class JoblistController extends ActionController { fputcsv($file, $dataToInsertArr); fclose($file); } catch (\RuntimeException $exception) { - throw new \RuntimeException($exception->getMessage()); + GeneralUtility::makeInstance(FlashMessage::class, $exception->getMessage()); + $this->redirect('applyFormAction'); } } diff --git a/Resources/Private/Templates/Joblist/ApplyForm.html b/Resources/Private/Templates/Joblist/ApplyForm.html index 4e0a9628ea47f987d2304900bd66fa1775aa803a..0d3eca449b30ed62e4ab98bb6f19b6eb9708c805 100644 --- a/Resources/Private/Templates/Joblist/ApplyForm.html +++ b/Resources/Private/Templates/Joblist/ApplyForm.html @@ -1,6 +1,7 @@ <f:layout name="Default" /> <f:section name="main"> + <f:flashMessages /> <f:form action="apply" controller="Joblist" method="post" objectName="applyData" object="{applyData}" enctype="multipart/form-data"> <f:if condition="{job}"> <f:form.hidden value="{job.jobId}" property="jobId" />