[TYPO3-dev] get filepath in Extbase
t3-dev at bworx.de
t3-dev at bworx.de
Wed Oct 7 11:58:47 CEST 2015
Hi,
I am not experienced with extbase so sorry for any stupid questions. I
have searched the web for a couple of hours and cant find a solution:
Some of my db entries (books) have a file (PDF) attached to them. When a
user fills out a form they should be sent the corresponding file. I send
the email thorugh the swiftmailer Instance. I have figured out how to
attach a file but I fail at getting the real file from the DB Reference.
All I get is "TYPO3\CMS\Extbase\Domain\Model\FileReference:157". Trying to
turn that into the originalResource has failed so far. What I have:
TCA
'file' => array(
'exclude' => 1,
'label' =>
'LLL:EXT:tx_test_ext/Resources/Private/Language/locallang_db.xlf:tx_test_ext_domain_model_book.file',
'config' =>
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig(
'file',
array('maxitems' => 1),
'pdf'
),
),
Model
/**
* Returns the file
*
* @return \TYPO3\CMS\Extbase\Domain\Model\FileReference $file
*/
public function getFile() {
return $this->file;
}
/**
* Sets the file
*
* @param \TYPO3\CMS\Extbase\Domain\Model\FileReference $file
* @return void
*/
public function setFile(\TYPO3\CMS\Extbase\Domain\Model\FileReference
$file) {
$this->file = $file;
}
Controller
$tempAttach1 = $book->getFile();
So I guess I need to somehow adjust the getFile function ... I tried
return $this->file->getOriginalResource(); amongst others but that just
kills the ext saying I'm trying to call to a member function
getOriginalResource() on a non-object - so I guess I need to turn it into
an object beforehand. But I have no clue how I shoould do this. Any hints?
Thanks, Jan
More information about the TYPO3-dev
mailing list