Skip to content
Snippets Groups Projects

[TASK] Remove the pagebrowser controller and let the view helper handle stuff

Merged Kevin Ditscheid requested to merge task_RemovePagebrowser into master
7 files
+ 135
260
Compare changes
  • Side-by-side
  • Inline
Files
7
@@ -123,15 +123,28 @@ class JoblistController extends ActionController {
$this->jobRepository = $jobRepository;
}
/**
* Initialize the indexAction to set the currentPageBrowserPage parameter
*
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\InvalidArgumentNameException
*/
public function initializeIndexAction() {
$currentPageBrowserPage = (int) GeneralUtility::_GP('tx_sgjobs_pagebrowser')['currentPage'];
if ($currentPageBrowserPage > 0) {
$this->request->setArgument('currentPageBrowserPage', $currentPageBrowserPage);
}
}
/**
* Show all job offers and options to manage them
*
* @param array $filters
* @param int $jobId
* @param int $currentPageBrowserPage
* @return void
* @throws \InvalidArgumentException
* @throws \TYPO3\CMS\Core\Context\Exception\AspectNotFoundException
*/
public function indexAction(array $filters = [], $jobId = NULL): void {
public function indexAction(array $filters = [], int $jobId = NULL, int $currentPageBrowserPage = 0): void {
if ($filters) {
$this->view->assign('selectedCountry', $filters['filterCountry']);
$this->view->assign('selectedCompany', $filters['filterCompany']);
@@ -167,7 +180,6 @@ class JoblistController extends ActionController {
} else {
// pagination logic
$offset = 0;
$currentPageBrowserPage = (int) GeneralUtility::_GP('tx_sgjobs_pagebrowser')['currentPage'];
if ($currentPageBrowserPage && $jobLimit) {
$offset = $currentPageBrowserPage * $jobLimit;
}
@@ -203,16 +215,15 @@ class JoblistController extends ActionController {
/**
* Renders the application form with an optional job
*
* @param JobApplication $applyData
* @param JobApplication|null $applyData
* @param string $error
* @param int $jobId
* @throws \TYPO3\CMS\Core\Context\Exception\AspectNotFoundException
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\InvalidArgumentNameException
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\UnsupportedRequestTypeException
* @throws \TYPO3\CMS\Core\Context\Exception\AspectNotFoundException
*/
public function applyFormAction(JobApplication $applyData = NULL, $error = NULL, $jobId = NULL): void {
if ($error !== NULL && $error !== '') {
public function applyFormAction(JobApplication $applyData = NULL, string $error = '', int $jobId = NULL): void {
if ($error !== '') {
$this->view->assign('internalError', $error);
$this->request->setArgument('error', NULL);
}
@@ -302,7 +313,6 @@ class JoblistController extends ActionController {
* @return void
* @throws NoSuchArgumentException
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\UnsupportedRequestTypeException
*/
protected function initializeApplyAction(): void {
try {
@@ -333,17 +343,14 @@ class JoblistController extends ActionController {
* @param string $folderName
* @return void
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException
* @throws \RuntimeException
* @throws \InvalidArgumentException
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\UnsupportedRequestTypeException
* @throws \TYPO3\CMS\Core\Resource\Exception\ResourceDoesNotExistException
*/
protected function submitApplicationFiles(JobApplication $applicationData, $folderName): void {
$resourceFactory = $this->objectManager->get(ResourceFactory::class);
$newName = \date('Ymd-His') . '_' . $applicationData->getJobId() . '-' . $applicationData->getFirstName()
. '-' . $applicationData->getLastName();
$storage = $resourceFactory->getStorageObject(1);
$applicationFilePath = Environment::getPublicPath() . '/' . $storage->getConfiguration()['basePath'] . 'JobApplication/' . $folderName .
$applicationFilePath = Environment::getPublicPath() . '/' . $storage->getConfiguration(
)['basePath'] . 'JobApplication/' . $folderName .
'/' . $newName . '.csv';
$this->writeApplicationFile($applicationData, $applicationFilePath);
}
@@ -363,9 +370,7 @@ class JoblistController extends ActionController {
$applyData->setPid($GLOBALS['TSFE']->id);
$job = $applyData->getJob();
// look for a configured default job, in case of unsolicited application
if (($job === '' || $job === NULL || $applyData->getJobId() === NULL)
&& $applyData->getCompany() !== NULL
) {
if ((!$job || $applyData->getJobId() === NULL) && $applyData->getCompany() !== NULL) {
$applyData->setJobId($applyData->getCompany()->getJobId());
}
@@ -378,7 +383,6 @@ class JoblistController extends ActionController {
$this->moveTmpFolder($folderName);
$this->submitApplicationFiles($applyData, $folderName);
/** @noinspection PhpMethodParametersCountMismatchInspection */
$mailService = $this->objectManager->get(
MailTemplateService::class, 'application_mail', 'sg_jobs',
$this->getApplicationMailMarkers($applyData)
@@ -426,8 +430,11 @@ class JoblistController extends ActionController {
$redirectPageUid = (int) $this->settings['redirectPage'];
if ($redirectPageUid) {
$url = $this->configurationManager->getContentObject()->getTypoLink_URL($redirectPageUid);
$this->redirectToUri($url);
$contentObject = $this->configurationManager->getContentObject();
if ($contentObject) {
$url = $contentObject->getTypoLink_URL($redirectPageUid);
$this->redirectToUri($url);
}
}
$this->redirect('applyForm');
@@ -448,7 +455,7 @@ class JoblistController extends ActionController {
* Assign filter values
*
* @param int $rootPageId
* @throws \InvalidArgumentException
* @throws \TYPO3\CMS\Core\Context\Exception\AspectNotFoundException
*/
protected function assignFilterValues($rootPageId): void {
$countries = $this->companyRepository->getAllCountries($rootPageId);
@@ -473,7 +480,7 @@ class JoblistController extends ActionController {
* @param JobApplication $applyData
* @return array
*/
protected function getApplicationMailMarkers($applyData): array {
protected function getApplicationMailMarkers(JobApplication $applyData): array {
$location = '';
if ($applyData->getCompany() !== NULL) {
$location = $applyData->getCompany()->getCity();
@@ -499,13 +506,36 @@ class JoblistController extends ActionController {
*
* @param JobApplication $data
* @param string $filePath
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\UnsupportedRequestTypeException
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException
* @throws \InvalidArgumentException
* @throws \RuntimeException
* @throws \TYPO3\CMS\Core\Resource\Exception\ResourceDoesNotExistException
*/
protected function writeApplicationFile(JobApplication $data, $filePath): void {
$coverLetter = '';
$coverLetterObject = $data->getCoverLetter();
if ($coverLetterObject) {
$coverLetterObject = $coverLetterObject->getOriginalResource();
if ($coverLetterObject) {
$coverLetter = $coverLetterObject->getPublicUrl();
}
}
$cv = '';
$cvObject = $data->getCv();
if ($cvObject) {
$cvObject = $cvObject->getOriginalResource();
if ($cvObject) {
$cv = $cvObject->getPublicUrl();
}
}
$certificate = '';
$certificateObject = $data->getCertificate();
if ($certificateObject) {
$certificateObject = $certificateObject->getOriginalResource();
if ($certificateObject) {
$certificate = $certificateObject->getPublicUrl();
}
}
$dataToInsertArr = [
$data->getJobId(),
$data->getFirstName(),
@@ -520,9 +550,9 @@ class JoblistController extends ActionController {
$data->getNationality(),
$data->getPhone(),
$data->getEmail(),
$data->getCoverLetter() === NULL ? '' : $data->getCoverLetter()->getOriginalResource()->getPublicUrl(),
$data->getCv() === NULL ? '' : $data->getCv()->getOriginalResource()->getPublicUrl(),
$data->getCertificate() === NULL ? '' : $data->getCertificate()->getOriginalResource()->getPublicUrl(),
$coverLetter,
$cv,
$certificate,
$data->getMessage()
];
@@ -583,7 +613,7 @@ class JoblistController extends ActionController {
/**
* If for any reason something goes wrong, delete the tmp upload folder
*
* @return string|void
* @return void
* @throws NoSuchArgumentException
*/
public function errorAction() {
Loading