Closed
Description
ATM, the documentation is a bit old and uncomplete. For exemple the doc tells to create the definition and then to tag it. So OLD 😂
For exemple, we could exemple how to enhance normalized data:
class TopicNormalizer implements NormalizerInterface
{
private $router;
private $normaliser;
public function __construct(UrlGeneratorInterface $router, ObjectNormalizer $normaliser)
{
$this->router = $router;
$this->normaliser = $normaliser;
}
public function normalize($topic, $format = null, array $context = array())
{
$data = $this->normaliser->normalize($topic, 'json', $context);
$data['href']['self'] = $this
->router
->generate(
'topic_show',
['id' => $topic->getId()],
UrlGeneratorInterface::ABSOLUTE_URL
)
;
return $data;
}
public function supportsNormalization($data, $format = null)
{
return $data instanceof Topic;
}
}