-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
I try to add audiofiles to a post using FileReference. Eventually only the first of a max of 4 is "recignized", displaying uid and pid in the resulting json, even though uid should not be used.
This is what I do:
// Add to ext_tables.sql
CREATE TABLE tx_jsonexample_domain_model_post (
[...],
audiofiles int(11) unsigned NOT NULL DEFAULT '0',
);
// Add to tx_jsonexample_domain_model_post.php TCA
'types' => [
'1' => [ 'showitem' => 'hidden, title, post_text, tags, audiofiles' ],
],
'columns' => [
'audiofiles' => [
'exclude' => true,
'label' => 'Audio files',
'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig(
'audiofiles',
[
'appearance' => [
'createNewRelationLinkTitle' => 'Add',
[...]
],
'foreign_types' => [
'0' => [
'showitem' => '
--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
--palette--;;filePalette'
],
\TYPO3\CMS\Core\Resource\File::FILETYPE_TEXT => [
[...]
],
[...]
],
'foreign_match_fields' => [
'fieldname' => 'audiofiles',
'tablenames' => 'tx_jsonexample_domain_model_post',
'table_local' => 'sys_file',
],
'maxitems' => 4
]
),
]
]
// Add to Domain/Model/Post
/**
* @var \TYPO3\CMS\Extbase\Domain\Model\FileReference
*/
protected $audiofiles;
public function __construct(string $title, string $postText)
{
[...];
$this->audiofiles = new \TYPO3\CMS\Extbase\Domain\Model\FileReference();
}
/**
* @return \TYPO3\CMS\Extbase\Domain\Model\FileReference $audiofiles
*/
public function getAudiofiles(): \TYPO3\CMS\Extbase\Domain\Model\FileReference
{
return $this->audiofiles;
}
// ...and eventually to Json View:
'posts' => [
'_descendAll' => [
'_descend' => [
'tags' => [ ... ],
'audiofiles' => [
'_descendAll' => [
'_only' => ['uid']
]
]
]
]
],
But when calling the RestAPI URL (via Postman), TYPO3 returns this error:
(1/1) TypeError
Return value of DanielGoerz\JsonExample\Domain\Model\Post::getAudiofiles() must be an instance of TYPO3\CMS\Extbase\Domain\Model\FileReference, null returned
in /var/www/html/packages/json_example/Classes/Domain/Model/Post.php line 45
(in line 45 is the 'getAudiofiles' method)
What do I have to do to be able to get potentially all 4 audio files from the post? Ideally displaying a link to the audio file?
Metadata
Metadata
Assignees
Labels
No labels