I want a few controllers which have methods like this:
public function syncAction(EntityManager $em)
{
$posts = $em->getRepository('App:Posts')->findAllByOwner($this->getUser());
return new JsonResponse(['ok' => true, 'posts' => $this->toJson($posts)]);
}
I want to add something like middleware to be automatically jsonify response from all actions of this controller. And be ablw to simple do this:
return new JsonResponse(['ok' => true, 'posts' => $posts]);
PS Also automatically serialize my instances.