Problem/Motivation
If Q&A array is empty, we shouldn't render the object at all. If we use a token for acceptedAnswer, and that token is empty, we render e.g.:
{
"@type": "FAQPage",
"mainEntity": {
"@type": "Question",
"acceptedAnswer": {
"@type": "Answer"
}
}
}
Steps to reproduce
Proposed resolution
Override SchemaQAPageMainEntity::output() like
public function output(): array {
$result = parent::output();
if (!isset($result['#attributes']['content'][0])) {
return [];
}
else {
return $result;
}
}
Remaining tasks
Patch.
User interface changes
API changes
Data model changes
None.
Comments
Comment #3
stefank commentedComment #6
guiu.rocafort.ferrerThe test needs to be updated.