Skip to content
Snippets Groups Projects
Commit ba611436 authored by Kevin Ditscheid's avatar Kevin Ditscheid
Browse files

[BUGFIX] Fix the FileReference handling for uploaded files in job applications

parent aacfe2cd
No related branches found
No related tags found
1 merge request!12Feature upgrade to9 lts
<?php
namespace SGalinski\SgJobs\Domain\Model;
/***************************************************************
* Copyright notice
/**
*
* (c) 2014 Helmut Hummel
* Copyright notice
*
* All rights reserved
* (c) sgalinski Internet Services (https://www.sgalinski.de)
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
* All rights reserved
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
*/
namespace SGalinski\SgJobs\Domain\Model;
/**
* Class FileReference
*
* @package SGalinski\SgJobs\Domain\Model
* @author Kevin Ditscheid <kevin.ditscheid@sgalinski.de>
*/
class FileReference extends \TYPO3\CMS\Extbase\Domain\Model\FileReference {
/**
* Uid of a sys_file
*
* @var int
*/
protected $originalFileIdentifier;
/**
* @param \TYPO3\CMS\Core\Resource\ResourceInterface $originalResource
*/
public function setOriginalResource(\TYPO3\CMS\Core\Resource\ResourceInterface $originalResource) {
$this->setFileReference($originalResource);
}
/**
* @param \TYPO3\CMS\Core\Resource\FileReference $originalResource
* @var string
*/
private function setFileReference(\TYPO3\CMS\Core\Resource\FileReference $originalResource) {
$this->originalResource = $originalResource;
$this->originalFileIdentifier = (int) $originalResource->getOriginalFile()->getUid();
}
protected $tablenames = 'tx_sgjobs_domain_model_job_application';
}
......@@ -27,8 +27,6 @@ namespace SGalinski\SgJobs\Domain\Model;
***************************************************************/
use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
use TYPO3\CMS\Extbase\Persistence\Generic\LazyLoadingProxy;
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
/**
* The JobApplication model
......@@ -135,19 +133,19 @@ class JobApplication extends AbstractEntity {
protected $email = '';
/**
* @var \SGalinski\SgJobs\Domain\Model\FileReference $coverLetter
* @var \TYPO3\CMS\Extbase\Domain\Model\FileReference $coverLetter
* @validate NotEmpty
*/
protected $coverLetter;
/**
* @var \SGalinski\SgJobs\Domain\Model\FileReference $cv
* @var \TYPO3\CMS\Extbase\Domain\Model\FileReference $cv
* @validate NotEmpty
*/
protected $cv;
/**
* @var \SGalinski\SgJobs\Domain\Model\FileReference $certificate
* @var \TYPO3\CMS\Extbase\Domain\Model\FileReference $certificate
* @validate NotEmpty
*/
protected $certificate;
......@@ -360,44 +358,44 @@ class JobApplication extends AbstractEntity {
}
/**
* @return \SGalinski\SgJobs\Domain\Model\FileReference
* @return \TYPO3\CMS\Extbase\Domain\Model\FileReference
*/
public function getCoverLetter() {
return $this->coverLetter;
}
/**
* @param \SGalinski\SgJobs\Domain\Model\FileReference $coverLetter
* @param \TYPO3\CMS\Extbase\Domain\Model\FileReference $coverLetter
*/
public function setCoverLetter(\SGalinski\SgJobs\Domain\Model\FileReference $coverLetter = NULL) {
public function setCoverLetter(\TYPO3\CMS\Extbase\Domain\Model\FileReference $coverLetter = NULL) {
$this->coverLetter = $coverLetter;
}
/**
* @return \SGalinski\SgJobs\Domain\Model\FileReference
* @return \TYPO3\CMS\Extbase\Domain\Model\FileReference
*/
public function getCv() {
return $this->cv;
}
/**
* @param \SGalinski\SgJobs\Domain\Model\FileReference $cv
* @param \TYPO3\CMS\Extbase\Domain\Model\FileReference $cv
*/
public function setCV(\SGalinski\SgJobs\Domain\Model\FileReference $cv = NULL) {
public function setCV(\TYPO3\CMS\Extbase\Domain\Model\FileReference $cv = NULL) {
$this->cv = $cv;
}
/**
* @return \SGalinski\SgJobs\Domain\Model\FileReference
* @return \TYPO3\CMS\Extbase\Domain\Model\FileReference
*/
public function getCertificate() {
return $this->certificate;
}
/**
* @param \SGalinski\SgJobs\Domain\Model\FileReference $certificate
* @param \TYPO3\CMS\Extbase\Domain\Model\FileReference $certificate
*/
public function setCertificate(\SGalinski\SgJobs\Domain\Model\FileReference $certificate = NULL) {
public function setCertificate(\TYPO3\CMS\Extbase\Domain\Model\FileReference $certificate = NULL) {
$this->certificate = $certificate;
}
......
......@@ -32,7 +32,7 @@ use TYPO3\CMS\Core\Resource\FileReference as FalFileReference;
use TYPO3\CMS\Core\Resource\ResourceFactory;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\PathUtility;
use TYPO3\CMS\Extbase\Domain\Model\FileReference;
use SGalinski\SgJobs\Domain\Model\FileReference;
use TYPO3\CMS\Extbase\Error\Error;
use TYPO3\CMS\Extbase\Object\ObjectManagerInterface;
use TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager;
......@@ -302,7 +302,7 @@ class UploadedFileReferenceConverter implements TypeConverterInterface {
* @param string $targetType
* @param array $convertedChildProperties
* @param PropertyMappingConfigurationInterface $configuration
* @return null|\TYPO3\CMS\Core\Resource\FileInterface|FileReference|Error
* @return null|FileReference|Error
* @api
*/
public function convertFrom(
......@@ -354,7 +354,7 @@ class UploadedFileReferenceConverter implements TypeConverterInterface {
* Import a resource and respect configuration given for properties
*
* @param array $uploadInfo
* @return \SGalinski\SgJobs\Domain\Model\FileReference|NULL
* @return FileReference|NULL
* @throws \InvalidArgumentException
* @throws TypeConverterException
* @throws \Exception
......@@ -419,10 +419,10 @@ class UploadedFileReferenceConverter implements TypeConverterInterface {
/**
* @param FalFile $file
* @return \SGalinski\SgJobs\Domain\Model\FileReference
* @return FileReference
*/
protected function createFileReferenceFromFalFileObject(FalFile $file
): \SGalinski\SgJobs\Domain\Model\FileReference {
): FileReference {
$fileReference = $this->resourceFactory->createFileReferenceObject(
[
'uid_local' => $file->getUid(),
......@@ -436,11 +436,10 @@ class UploadedFileReferenceConverter implements TypeConverterInterface {
/**
* @param FalFileReference $falFileReference
* @return \SGalinski\SgJobs\Domain\Model\FileReference
* @return FileReference
*/
protected function createFileReferenceFromFalFileReferenceObject(FalFileReference $falFileReference
): \SGalinski\SgJobs\Domain\Model\FileReference {
/** @var \SGalinski\SgJobs\Domain\Model\FileReference $fileReference */
): FileReference {
$fileReference = $this->objectManager->get(FileReference::class);
$fileReference->setOriginalResource($falFileReference);
return $fileReference;
......
......@@ -73,7 +73,7 @@ return call_user_func(
'columns' => [
'sys_language_uid' => [
'exclude' => TRUE,
'label' => 'LLL:EXT:lang/Resources/Private/Language/locallang_general.xml:LGL.language',
'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.language',
'config' => [
'type' => 'select',
'special' => 'languages',
......@@ -82,7 +82,7 @@ return call_user_func(
'l10n_parent' => [
'displayCond' => 'FIELD:sys_language_uid:>:0',
'exclude' => TRUE,
'label' => 'LLL:EXT:lang/Resources/Private/Language/locallang_general.xml:LGL.l18n_parent',
'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.l18n_parent',
'config' => [
'type' => 'select',
'items' => [
......@@ -98,7 +98,7 @@ return call_user_func(
],
],
't3ver_label' => [
'label' => 'LLL:EXT:lang/Resources/Private/Language/locallang_general.xml:LGL.versionLabel',
'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.versionLabel',
'config' => [
'type' => 'input',
'size' => 30,
......@@ -114,7 +114,7 @@ return call_user_func(
],
'hidden' => [
'exclude' => TRUE,
'label' => 'LLL:EXT:lang/Resources/Private/Language/locallang_general.xml:LGL.hidden',
'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.hidden',
'config' => [
'type' => 'check',
],
......@@ -122,7 +122,7 @@ return call_user_func(
'starttime' => [
'exclude' => TRUE,
'l10n_mode' => 'mergeIfNotBlank',
'label' => 'LLL:EXT:lang/Resources/Private/Language/locallang_general.xml:LGL.starttime',
'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.starttime',
'config' => [
'type' => 'input',
'size' => 13,
......@@ -138,7 +138,7 @@ return call_user_func(
'endtime' => [
'exclude' => TRUE,
'l10n_mode' => 'mergeIfNotBlank',
'label' => 'LLL:EXT:lang/Resources/Private/Language/locallang_general.xml:LGL.endtime',
'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.endtime',
'config' => [
'type' => 'input',
'size' => 13,
......
config.tx_extbase {
persistence {
classes {
SGalinski\SgJobs\Domain\Model\FileReference {
mapping {
tableName = sys_file_reference
}
}
SGalinski\SgJobs\Domain\Model\JobApplication {
mapping {
tableName = tx_sgjobs_domain_model_job_application
......
config.tx_extbase {
persistence {
classes {
SGalinski\SgJobs\Domain\Model\FileReference {
mapping {
tableName = sys_file_reference
columns {
uid_local.mapOnProperty = originalFileIdentifier
}
}
}
}
}
objects {
TYPO3\CMS\Extbase\Domain\Model\FileReference.className = SGalinski\SgJobs\Domain\Model\FileReference
}
}
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