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 {
* @return void
* @throws \InvalidArgumentException
*/
public function indexAction(array $filters = [], $jobId = null) {
public function indexAction(array $filters = [], $jobId = NULL) {
if ($filters) {
$this->view->assign('selectedCountry', $filters['filterCountry']);
$this->view->assign('selectedCompany', $filters['filterCompany']);
......@@ -94,7 +94,16 @@ class JoblistController extends ActionController {
$jobLimit = (int) $this->settings['jobLimit'];
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;
} else {
// pagination logic
......@@ -123,6 +132,7 @@ class JoblistController extends ActionController {
* @param JobApplication $applyData
* @param string $error
* @param int $uid
* @throws \InvalidArgumentException
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\InvalidArgumentNameException
*/
public function applyFormAction(JobApplication $applyData = NULL, $error = NULL, $uid = NULL) {
......@@ -135,19 +145,25 @@ class JoblistController extends ActionController {
try {
$folderName = $this->request->getArgument('folderName');
} 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) {
$folderName = md5(uniqid('sgjobs-', TRUE));
$this->request->setArgument('folderName', $folderName);
}
$this->view->assign('folderName', $folderName);
$jobData = NULL;
$job = NULL;
if (!$uid !== NULL) {
/** @var Job $jobData */
$jobData = $this->jobRepository->findByUid($uid);
$this->view->assign('job', $jobData);
/** @var Job $job */
$job = $this->jobRepository->findByUid($uid);
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
......@@ -164,8 +180,8 @@ class JoblistController extends ActionController {
if ($applyData === NULL) {
/** @noinspection CallableParameterUseCaseInTypeContextInspection */
$applyData = $this->objectManager->get(JobApplication::class);
if ($jobData) {
$applyData->setJobId($jobData->getJobId());
if ($job) {
$applyData->setJobId($job->getJobId());
}
}
......@@ -238,8 +254,11 @@ class JoblistController extends ActionController {
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException
* @throws \InvalidArgumentException
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\InvalidArgumentNameException
* @throws NoSuchArgumentException
*/
public function applyAction(JobApplication $applyData) {
$folderName = $this->request->getArgument('folderName');
try {
$applyData->setPid($GLOBALS['TSFE']->id);
......@@ -258,7 +277,6 @@ class JoblistController extends ActionController {
$this->jobApplicationRepository->update($applyData);
}
$folderName = $this->request->getArgument('folderName');
$this->submitApplicationFiles($applyData, $folderName);
/** @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