TYPO3-Headless / headless

TYPO3 Headless JSON API providing content for PWA application (e.g. javaScript apps like nuxt-typo3)
https://t3headless.io
GNU General Public License v2.0
156 stars 57 forks source link

dataProcessor returning empty array if no "as" conf value found in typoscript #122

Open ironeddie opened 4 years ago

ironeddie commented 4 years ago

Hi guys, i am struggling with dataProcessors in custom content elements and headless… assuming a content element dataProcessing like following:

tt_content.borderelement.dataProcessing {
    1001 = Border\SitePackage\Processor\ContentElementsProcessor
}

and finding in extension code FriendsOfTYPO3\Headless\ContentObject\JsonContentObject on line 205-210 the code is searching for a “as” definition in conf, otherwise it will return an empty array… this is perhaps not the right behaviour as the data processor for the content element itself will fill the data array to my proper needs. is this a bug? (bearbeitet)

lukaszuznanski commented 4 years ago

it's intented because we need to know which key in data from dataProcessors we should display, I would like to set some default fallback, but current implementation of dataProcessors is inconsistent, as there is no standardization in terms of default "as" value along dataProcessors, so we need to set "as" in dataProcessor. On upcoming codesprint I would like to take care of this issue.

ironeddie commented 4 years ago

as i changed line 211 in JsonContentObject.php from return $dataProcessingData; to return (empty($dataProcessingData) ? $data : $dataProcessingData);

all my data is now rendered properly in the returning result from request. Maybe this is already a workaround and a possible solution for this issue...

please let me know if you think this may lead to unpredictable behaviour on other side. thank you.

lukaszuznanski commented 4 years ago

Hi,

I guess, your solution renders all data that comes from dataProcessor if you don't specify 'as'?

It's ok, as if you don't set 'as' then you have whole output. Could you provide PR with this change?

lukaszuznanski commented 4 years ago

@gordon81 taking the issue