Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
sg_jobs
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TYPO3
sg_jobs
Commits
f685d320
Commit
f685d320
authored
1 year ago
by
Stefan Galinski
Browse files
Options
Downloads
Patches
Plain Diff
[TASK] Simplify the code
parent
6d33c9ef
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Classes/Controller/JoblistController.php
+62
-71
62 additions, 71 deletions
Classes/Controller/JoblistController.php
with
62 additions
and
71 deletions
Classes/Controller/JoblistController.php
+
62
−
71
View file @
f685d320
...
...
@@ -417,7 +417,7 @@ class JoblistController extends ActionController {
}
/**
*
Mov
es the application
files from temporary to permanent storag
e
*
Writ
es the application
CSV fil
e
*
* @param JobApplication $applicationData
* @param string $folderName
...
...
@@ -431,7 +431,63 @@ class JoblistController extends ActionController {
$storage
=
$resourceFactory
->
getStorageObject
(
1
);
$applicationFilePath
=
Environment
::
getPublicPath
()
.
'/'
.
$storage
->
getConfiguration
()[
'basePath'
]
.
'JobApplication/'
.
$folderName
.
'/'
.
$newName
.
'.csv'
;
$this
->
writeApplicationFile
(
$applicationData
,
$applicationFilePath
);
$coverLetter
=
''
;
$coverLetterObject
=
$applicationData
->
getCoverLetter
();
if
(
$coverLetterObject
)
{
$coverLetterObject
=
$coverLetterObject
->
getOriginalResource
();
if
(
$coverLetterObject
)
{
$coverLetter
=
$coverLetterObject
->
getPublicUrl
();
}
}
$cv
=
''
;
$cvObject
=
$applicationData
->
getCv
();
if
(
$cvObject
)
{
$cvObject
=
$cvObject
->
getOriginalResource
();
if
(
$cvObject
)
{
$cv
=
$cvObject
->
getPublicUrl
();
}
}
$certificate
=
''
;
$certificateObject
=
$applicationData
->
getCertificate
();
if
(
$certificateObject
)
{
$certificateObject
=
$certificateObject
->
getOriginalResource
();
if
(
$certificateObject
)
{
$certificate
=
$certificateObject
->
getPublicUrl
();
}
}
$dataToInsertArr
=
[
$applicationData
->
getJobId
(),
$applicationData
->
getFirstName
(),
$applicationData
->
getLastName
(),
$applicationData
->
getGender
(),
$applicationData
->
getCountry
(),
$applicationData
->
getBirthDate
(),
$applicationData
->
getEducation
(),
$applicationData
->
getStreet
(),
$applicationData
->
getZip
(),
$applicationData
->
getCity
(),
$applicationData
->
getNationality
(),
$applicationData
->
getPhone
(),
$applicationData
->
getEmail
(),
$coverLetter
,
$cv
,
$certificate
,
$applicationData
->
getMessage
()
];
try
{
GeneralUtility
::
mkdir_deep
(
\dirname
(
$applicationFilePath
));
$file
=
\fopen
(
$applicationFilePath
,
'wb+'
);
\fputcsv
(
$file
,
$dataToInsertArr
);
\fclose
(
$file
);
}
catch
(
\RuntimeException
$exception
)
{
$this
->
redirect
(
'applyForm'
,
NULL
,
NULL
,
[
'error'
=>
$exception
->
getMessage
()]);
}
}
/**
...
...
@@ -639,71 +695,6 @@ class JoblistController extends ActionController {
];
}
/**
* Writes the application files
*
* @param JobApplication $data
* @param string $filePath
* @throws StopActionException
*/
protected
function
writeApplicationFile
(
JobApplication
$data
,
string
$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
(),
$data
->
getLastName
(),
$data
->
getGender
(),
$data
->
getCountry
(),
$data
->
getBirthDate
(),
$data
->
getEducation
(),
$data
->
getStreet
(),
$data
->
getZip
(),
$data
->
getCity
(),
$data
->
getNationality
(),
$data
->
getPhone
(),
$data
->
getEmail
(),
$coverLetter
,
$cv
,
$certificate
,
$data
->
getMessage
()
];
try
{
GeneralUtility
::
mkdir_deep
(
\dirname
(
$filePath
));
$file
=
\fopen
(
$filePath
,
'wb+'
);
\fputcsv
(
$file
,
$dataToInsertArr
);
\fclose
(
$file
);
}
catch
(
\RuntimeException
$exception
)
{
$this
->
redirect
(
'applyForm'
,
NULL
,
NULL
,
[
'error'
=>
$exception
->
getMessage
()]);
}
}
/**
* Move the temp folder to its proper location
*
...
...
@@ -722,7 +713,7 @@ class JoblistController extends ActionController {
/** @var ResourceFactory $resourceFactory */
$resourceFactory
=
GeneralUtility
::
makeInstance
(
ResourceFactory
::
class
);
$storage
=
$resourceFactory
->
getStorageObject
(
1
);
$storage
=
$resourceFactory
->
getStorageObject
(
1
);
// fileadmin
$newFolder
=
$tempFolder
=
NULL
;
$folder
=
$storage
->
getFolder
(
UploadController
::
JOB_APPLICATION_FOLDER
);
...
...
@@ -774,7 +765,7 @@ class JoblistController extends ActionController {
}
$usableFile
=
$storage
->
copyFile
(
$usableFile
,
$newFolder
,
$newFilename
);
}
elseif
(
!
$newFolder
->
hasFile
(
$newFilename
))
{
// when we reload etc. this image might already be moved.
// when we reload
,
etc. this image might already be moved.
/** @noinspection PhpUnreachableStatementInspection */
$singleFileToMove
=
$storage
->
getFileInFolder
(
$basename
,
$tempFolder
);
$usableFile
=
$storage
->
moveFile
(
$singleFileToMove
,
$newFolder
,
$newFilename
);
...
...
@@ -801,7 +792,7 @@ class JoblistController extends ActionController {
}
/**
*
r
eturns currently set allowedFiles
*
R
eturns currently set allowedFiles
*
* @return mixed
*/
...
...
@@ -822,7 +813,7 @@ class JoblistController extends ActionController {
$tempFolder
=
$storage
->
getFolder
(
'/JobApplication/'
.
$folderName
);
$storage
->
deleteFolder
(
$tempFolder
,
TRUE
);
}
catch
(
\Exception
$exception
)
{
// folder is already deleted for some reason
//
the
folder is already deleted for some reason
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment