In a custom TYPO3 8.7.12 extbase extension I am unable to f:debug
items in templates.
We are in the listAction controller and simply do:
$institutions = $this->institutionRepository->findAll();
$this->view->assignMultiple([
'institutions' => $institutions,
// ... pagination limit ...
]
);
And in the template:
<f:debug>
{institutions}
</f:debug>
This returns
- sometimes the string 'Array' in the fluid debugger (can't reproduce now)
- When the code is on 3 lines:
#1273753083: Cannot cast object of type "TYPO3\CMS\Extbase\Persistence\Generic\QueryResult" to string.
- Or also
#1273753083: Cannot cast object of type "TYPO3\CMS\Extbase\Persistence\Generic\LazyObjectStorage" to string.
- When the code is on 1 line:
#1234386924: Cannot create empty instance of the class "TYPO3\CMS\Extbase\Persistence\ObjectStorage" because it does not implement the TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface.
If I loop through {institutions} with f:for
and then f:debug
:
<f:for each="{institutions}" as="institution" iteration="i">
<f:debug>
{institution}
</f:debug>
</f:for>
I get the first property of the object, e.g. the name.
EDIT: this is due to a __toString()
magic method in the model. If I remove it, instead I get the namespace and uid STUBR\Extension\Domain\Model\Institution:55
– this looks again as if the object isn't rendered.
Wait... php.net says The __toString() method allows a class to decide how it will react when it is treated like a string
. So could something be treating (typecasting?) the object as a string?
Working with the properties is normal, the issue just occurs when trying to print the whole object.
Where should I look? Lazy loading? There are some lazy loading properties, but not that many. Or maybe something is missing from the class? Or is there a workaround.
PS:
- Unable to print_r or var_dump the query result, I get a memory limit error.
- I saw https://wiki.typo3.org/Exception/CMS/1234386924 but
initStorageObjects()
is already called in the constructor
simple $this->view->assign('institutions', $institutions)
andremove @lazy
: I did, no difference.Did you try debug() in your controller?
There's no such php command, what do you mean? print_r uses too much memory – Urs\TYPO3\CMS\Core\Utility\DebugUtility::debug
works perfectly and produces the same output as expected from f:debug – Urs