typo3fluidextbasetypo3-8.7.x

How to debug in TYPO3 if <f:debug> returns strings instead of object?


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

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:


Solution

  • To answer the question;

    <f:debug>{institutions}</f:debug>
    

    will be parsed as an object, but any whitespace inside will make it parse as a string so.