[TYPO3-mvc] n:1 get uid
Jacco van der Post
jacco at id-internetservices.com
Sun Dec 14 15:38:49 CET 2014
Hi
g4-lisz at tonarchiv.ch schreef op 13-12-2014 23:38:
>
> You need to replace the passthrough TCA with a config that references to
> the right table, like:
>
> 'media' => array(
> 'config' => array(
> 'type' => 'select',
> 'foreign_table' => 'tx_xx_domain_model_media',
> 'minitems' => 0,
> 'maxitems' => 1,
> ),
> ),
>
Thanks for your reaction, I solved it without changing the TCA. It is in
fact easy, but not I could not find any examples, so it took me some time :
In the model Comment.php I added :
/**
* Media
*
* @var \JaccovanderPost\Xxx\Domain\Model\Media
*/
protected $media = NULL;
/**
* Returns the media
*
* @return \JaccovanderPost\Xxx\Domain\Model\Media $media
*/
public function getMedia() {
return $this->media;
}
Now in the Comment controller I have access to the parent object (after
inserting the media repository) :
$mediaItem = $comment->getMedia();
And stuff like this
$mediaItem->getUID();
$mediaItem->getTitle();
Etc.
Would be nice if in the extension builder a getter and setter for access
to a parent object would be automatically created for n:1 relations.
--
Kind Regards
Jacco van der Post
More information about the TYPO3-project-typo3v4mvc
mailing list