Skip to content
Snippets Groups Projects
Commit 2e16bea0 authored by Stefan Galinski's avatar Stefan Galinski :video_game:
Browse files

[FEATURE] Cleanups and add the title / description for each single view

parent 7116ce80
No related branches found
No related tags found
No related merge requests found
...@@ -76,7 +76,7 @@ class JoblistController extends ActionController { ...@@ -76,7 +76,7 @@ class JoblistController extends ActionController {
* @return void * @return void
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
*/ */
public function indexAction(array $filters = [], $jobId = null) { public function indexAction(array $filters = [], $jobId = NULL) {
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']);
...@@ -94,7 +94,16 @@ class JoblistController extends ActionController { ...@@ -94,7 +94,16 @@ class JoblistController extends ActionController {
$jobLimit = (int) $this->settings['jobLimit']; $jobLimit = (int) $this->settings['jobLimit'];
if ($jobId) { if ($jobId) {
$jobs = [$this->jobRepository->findByUid($jobId)]; /** @var Job $job */
$job = $this->jobRepository->findByUid($jobId);
if (!$job) {
throw new \InvalidArgumentException('Given Job Id is invalid!');
}
$GLOBALS['TSFE']->page['titlebyextension'] = $job->getTitle();
$GLOBALS['TSFE']->page['description'] = substr($job->getDescription(), 0, 200);
$jobs = [$job];
$numberOfPages = 1; $numberOfPages = 1;
} else { } else {
// pagination logic // pagination logic
...@@ -123,6 +132,7 @@ class JoblistController extends ActionController { ...@@ -123,6 +132,7 @@ class JoblistController extends ActionController {
* @param JobApplication $applyData * @param JobApplication $applyData
* @param string $error * @param string $error
* @param int $uid * @param int $uid
* @throws \InvalidArgumentException
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\InvalidArgumentNameException * @throws \TYPO3\CMS\Extbase\Mvc\Exception\InvalidArgumentNameException
*/ */
public function applyFormAction(JobApplication $applyData = NULL, $error = NULL, $uid = NULL) { public function applyFormAction(JobApplication $applyData = NULL, $error = NULL, $uid = NULL) {
...@@ -135,19 +145,25 @@ class JoblistController extends ActionController { ...@@ -135,19 +145,25 @@ class JoblistController extends ActionController {
try { try {
$folderName = $this->request->getArgument('folderName'); $folderName = $this->request->getArgument('folderName');
} catch (\Exception $exception) { } catch (\Exception $exception) {
// nope // this happens for the initial call, but works for any follow-up call as the form validation
// throws you back to this one if something has failed
} }
if ($folderName === NULL) { if ($folderName === NULL) {
$folderName = md5(uniqid('sgjobs-', TRUE)); $folderName = md5(uniqid('sgjobs-', TRUE));
$this->request->setArgument('folderName', $folderName); $this->request->setArgument('folderName', $folderName);
} }
$this->view->assign('folderName', $folderName); $this->view->assign('folderName', $folderName);
$jobData = NULL; $job = NULL;
if (!$uid !== NULL) { if (!$uid !== NULL) {
/** @var Job $jobData */ /** @var Job $job */
$jobData = $this->jobRepository->findByUid($uid); $job = $this->jobRepository->findByUid($uid);
$this->view->assign('job', $jobData); if ($job) {
$GLOBALS['TSFE']->page['titlebyextension'] = $job->getTitle();
$GLOBALS['TSFE']->page['description'] = substr($job->getDescription(), 0, 200);
}
$this->view->assign('job', $job);
} }
// display country options // display country options
...@@ -164,8 +180,8 @@ class JoblistController extends ActionController { ...@@ -164,8 +180,8 @@ class JoblistController extends ActionController {
if ($applyData === NULL) { if ($applyData === NULL) {
/** @noinspection CallableParameterUseCaseInTypeContextInspection */ /** @noinspection CallableParameterUseCaseInTypeContextInspection */
$applyData = $this->objectManager->get(JobApplication::class); $applyData = $this->objectManager->get(JobApplication::class);
if ($jobData) { if ($job) {
$applyData->setJobId($jobData->getJobId()); $applyData->setJobId($job->getJobId());
} }
} }
...@@ -238,8 +254,11 @@ class JoblistController extends ActionController { ...@@ -238,8 +254,11 @@ class JoblistController extends ActionController {
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException * @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\InvalidArgumentNameException * @throws \TYPO3\CMS\Extbase\Mvc\Exception\InvalidArgumentNameException
* @throws NoSuchArgumentException
*/ */
public function applyAction(JobApplication $applyData) { public function applyAction(JobApplication $applyData) {
$folderName = $this->request->getArgument('folderName');
try { try {
$applyData->setPid($GLOBALS['TSFE']->id); $applyData->setPid($GLOBALS['TSFE']->id);
...@@ -258,7 +277,6 @@ class JoblistController extends ActionController { ...@@ -258,7 +277,6 @@ class JoblistController extends ActionController {
$this->jobApplicationRepository->update($applyData); $this->jobApplicationRepository->update($applyData);
} }
$folderName = $this->request->getArgument('folderName');
$this->submitApplicationFiles($applyData, $folderName); $this->submitApplicationFiles($applyData, $folderName);
/** @noinspection PhpMethodParametersCountMismatchInspection */ /** @noinspection PhpMethodParametersCountMismatchInspection */
......
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