techpixel techpixel - 1 month ago 13
PHP Question

TYPO3 how to get nested private members

Here is the data struct in question:

TYPO3\CMS\Extbase\Persistence\Generic\QueryResultprototypeobject (2 items)
0 => Plistvendor\Plistkey\Domain\Model\Partnerprototypepersistent entity (uid=16, pid=50)
1 => Plistvendor\Plistkey\Domain\Model\Partnerprototypepersistent entity (uid=17, pid=50)
name => 'Egal' (4 chars)
nachname => 'Nachname' (8 chars)
position => 'position2' (9 chars)
adresse => 'adresse 123 lorem ipsum' (24 chars)
land => 'Deutschland' (11 chars)
bild => TYPO3\CMS\Extbase\Domain\Model\FileReferenceprototypepersistent entity (uid=98, pid=50)
skype => 'skypename' (9 chars)
telefon => '90853490583094' (14 chars)
email => 'mail@email.de' (13 chars)
division => TYPO3\CMS\Extbase\Persistence\Generic\LazyObjectStorageprototypeobject (1 items)
language => TYPO3\CMS\Extbase\Persistence\Generic\LazyObjectStorageprototypeobject (1 items)
000000004dac554500000000513665c6 => Plistvendor\Plistkey\Domain\Model\Languageprototypepersistent entity (uid=6, pid=50)
name => 'en' (2 chars)
uid => 6 (integer)
_localizedUid => 6 (integer)modified
_languageUid => 1 (integer)modified
_versionedUid => 6 (integer)modified
pid => 50 (integer)
uid => 17 (integer)
_localizedUid => 17 (integer)modified
_languageUid => -1 (integer)modified
_versionedUid => 17 (integer)modified
pid => 50 (integer)


Now my Question is how can I access
_languageUid
in either Fluid or PHP?

For further refference here is my controller code. I know it's pretty bad so I'm open to any suggestions that wouldn't cost too much time.

public function listAction() {
$lang = $_GET['L'];
$partners = $this->partnerRepository->GetAll();
foreach ($partners as $key => $value) {
foreach ($value->getlanguage() as $key => $lval) {
echo $lval;
}
}
$this->view->assignMultiple(array('partners' => $partners));
}


In this controller I can do echo
$lval->getUid();
and it will return the language Uid however I need to acces the
_languageUid
/
sys_language_uid
.

Answer

You need a public getter method for this property, otherwise you can't get it with fluid. Take an example at https://github.com/TYPO3-extensions/news/blob/master/Classes/Domain/Model/News.php#L1158-L1161

public function getSysLanguageUid()
{
    return $this->_languageUid;
}

In PHP, you can use the method _getProperty('_languageUid')

Comments