render = $render; } public function normalize($socialIssue, $format = null, array $context = []) { /** @var SocialIssue $socialIssue */ switch ($format) { case 'json': return [ 'type' => 'social_issue', 'id' => $socialIssue->getId(), 'parent_id' => $socialIssue->hasParent() ? $socialIssue->getParent()->getId() : null, 'children_ids' => $socialIssue->getChildren()->map(static function (SocialIssue $si) { return $si->getId(); }), 'title' => $socialIssue->getTitle(), 'text' => $this->render->renderString($socialIssue, []), ]; case 'docgen': if (null === $socialIssue) { return ['id' => 0, 'title' => '', 'text' => '']; } return [ 'id' => $socialIssue->getId(), 'title' => $socialIssue->getTitle(), 'text' => $this->render->renderString($socialIssue, []), ]; } } public function supportsNormalization($data, $format = null, array $context = []) { if ($data instanceof SocialIssue && 'json' === $format) { return true; } if ('docgen' === $format) { if ($data instanceof SocialIssue) { return true; } if (null === $data && SocialIssue::class === ($context['docgen:expects'] ?? null)) { return true; } } return false; } }