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
f04c95e4
Commit
f04c95e4
authored
7 years ago
by
Sergiu-Lucian Petrica
Browse files
Options
Downloads
Patches
Plain Diff
WIP make file upload move files correctly on form submit
parent
4deaf9fb
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Classes/Controller/JoblistController.php
+22
-14
22 additions, 14 deletions
Classes/Controller/JoblistController.php
Classes/Domain/Model/JobApplication.php
+3
-3
3 additions, 3 deletions
Classes/Domain/Model/JobApplication.php
with
25 additions
and
17 deletions
Classes/Controller/JoblistController.php
+
22
−
14
View file @
f04c95e4
...
...
@@ -35,6 +35,7 @@ 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
...
...
@@ -103,7 +104,8 @@ class JoblistController extends ActionController {
*/
public
function
applyAction
(
JobApplication
$applyData
)
{
try
{
$this
->
submitApplicationFiles
(
$applyData
);
$folderName
=
$this
->
request
->
getArgument
(
'folderName'
);
$this
->
submitApplicationFiles
(
$applyData
,
$folderName
);
/** @noinspection PhpMethodParametersCountMismatchInspection */
$mailService
=
$this
->
objectManager
->
get
(
...
...
@@ -143,22 +145,28 @@ class JoblistController extends ActionController {
* @throws \Exception
*/
protected
function
initializeApplyAction
()
{
if
(
$this
->
request
->
hasArgument
(
'folderName'
))
{
$uniqueFolderName
=
$this
->
request
->
getArgument
(
'folderName'
);
}
else
{
$uniqueFolderName
=
uniqid
(
'sgjobs-'
,
TRUE
);
}
try
{
$this
->
handleFileUpload
(
'coverLetter'
);
$this
->
handleFileUpload
(
'cv'
);
$this
->
handleFileUpload
(
'certificates'
);
$this
->
handleFileUpload
(
'coverLetter'
,
$uniqueFolderName
);
$this
->
handleFileUpload
(
'cv'
,
$uniqueFolderName
);
$this
->
handleFileUpload
(
'certificates'
,
$uniqueFolderName
);
}
catch
(
\Exception
$e
)
{
// possible errors, because of wrong mails
// @TODO output them in some way?
}
$propertyMappingConfiguration
=
$this
->
arguments
->
getArgument
(
'applyData'
)
->
getPropertyMappingConfiguration
();
$propertyMappingConfiguration
->
forProperty
(
'coverLetter'
)
->
allowAllProperties
();
$propertyMappingConfiguration
->
forProperty
(
'cv'
)
->
allowAllProperties
();
$propertyMappingConfiguration
->
forProperty
(
'certificates'
)
->
allowAllProperties
();
$uploadedFiles
=
$this
->
getExistingApplicationFiles
(
$
GLOBALS
[
'TSFE'
]
->
fe_user
->
id
);
$uploadedFiles
=
$this
->
getExistingApplicationFiles
(
$
uniqueFolderName
);
$this
->
request
->
setArgument
(
'uploadedFiles'
,
$uploadedFiles
);
$this
->
request
->
setArgument
(
'folderName'
,
$uniqueFolderName
);
}
/**
...
...
@@ -240,8 +248,8 @@ class JoblistController extends ActionController {
/**
* Moves the application files from temporary to permanent storage
*
* @param string $folder
* @param JobApplication $applicationData
* @param string $folderName
* @return void
* @throws \TYPO3\CMS\Core\Resource\Exception\ExistingTargetFolderException
* @throws \TYPO3\CMS\Core\Resource\Exception\InvalidTargetFolderException
...
...
@@ -253,13 +261,13 @@ class JoblistController extends ActionController {
* @throws \Exception
* @throws \InvalidArgumentException
*/
private
function
submitApplicationFiles
(
JobApplication
$applicationData
)
{
private
function
submitApplicationFiles
(
JobApplication
$applicationData
,
$folderName
)
{
$objectManager
=
GeneralUtility
::
makeInstance
(
ObjectManager
::
class
);
$resourceFactory
=
$objectManager
->
get
(
ResourceFactory
::
class
);
$storage
=
$resourceFactory
->
getStorageObject
(
1
);
$newName
=
date
(
'Ymd-His'
)
.
'_'
.
$applicationData
->
getFirstName
();
$sourceFolder
=
$storage
->
getFolder
(
'/Extension/temp/'
.
uniqid
(
'sgjobs-'
,
TRUE
)
);
$sourceFolder
=
$storage
->
getFolder
(
'/Extension/temp/'
.
$folderName
);
$subFolders
=
$storage
->
getFoldersInFolder
(
$sourceFolder
);
$fileNames
=
[];
...
...
@@ -365,6 +373,7 @@ class JoblistController extends ActionController {
/**
* @param string $fieldName
* @param string $folderName
* @return array
* @throws \UnexpectedValueException
* @throws \TYPO3\CMS\Core\Resource\Exception\InsufficientFolderWritePermissionsException
...
...
@@ -374,19 +383,18 @@ class JoblistController extends ActionController {
* @throws \InvalidArgumentException
* @throws \TYPO3\CMS\Core\Resource\Exception
*/
private
function
handleFileUpload
(
$fieldName
=
''
):
array
{
private
function
handleFileUpload
(
$fieldName
,
$folderName
):
array
{
$data
=
[];
$namespace
=
key
(
$_FILES
);
$applicationId
=
$GLOBALS
[
'TSFE'
]
->
fe_user
->
id
;
$objectManager
=
GeneralUtility
::
makeInstance
(
ObjectManager
::
class
);
$resourceFactory
=
$objectManager
->
get
(
ResourceFactory
::
class
);
$storage
=
$resourceFactory
->
getStorageObject
(
1
);
if
(
!
$storage
->
hasFolder
(
'/Extension/temp/'
.
$
applicationId
.
'/'
.
$fieldName
))
{
$storage
->
createFolder
(
'/Extension/temp/'
.
$
applicationId
.
'/'
.
$fieldName
);
if
(
!
$storage
->
hasFolder
(
'/Extension/temp/'
.
$
folderName
.
'/'
.
$fieldName
))
{
$storage
->
createFolder
(
'/Extension/temp/'
.
$
folderName
.
'/'
.
$fieldName
);
}
$targetFalDirectory
=
'1:/Extension/temp/'
.
$
applicationId
.
'/'
.
$fieldName
;
$targetFalDirectory
=
'1:/Extension/temp/'
.
$
folderName
.
'/'
.
$fieldName
;
// Register every upload field from the form:
$this
->
registerUploadField
(
$data
,
$namespace
,
$fieldName
,
$targetFalDirectory
);
...
...
This diff is collapsed.
Click to expand it.
Classes/Domain/Model/JobApplication.php
+
3
−
3
View file @
f04c95e4
...
...
@@ -121,19 +121,19 @@ class JobApplication extends AbstractEntity {
/**
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference> $coverLetter
*
@validate NotEmpty
*
*/
protected
$coverLetter
;
/**
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference> $cv
*
@validate NotEmpty
*
*/
protected
$cv
;
/**
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference> $certificates
*
@validate NotEmpty
*
*/
protected
$certificates
;
...
...
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