Хабр Курсы для всех
РЕКЛАМА
Практикум, Хекслет, SkyPro, авторские курсы — собрали всех и попросили скидки. Осталось выбрать!
fos_rest:
serializer:
serialize_null: true /**
* @param $id
* @return \Symfony\Component\HttpFoundation\Response
* @View(serializerGroups={"user"})
*/
public function getUserAction($id)
{
$user = $this->getDoctrine()->getRepository('AppBundle:User')->find($id);
if (!$user instanceof User) {
throw new NotFoundHttpException('User not found');
}
$view = $this->view($user, 200);
return $this->handleView($view);
} /**
* @Common\Annotation\SerializationGroups({"manager_app__user_details"})
*/
public function detailsAction(Common\Entity\User $entity)
{
return $entity
} $user = $this->getDoctrine()->getRepository('AppBundle:User')->find($id);
if (!$user instanceof User) {
throw new NotFoundHttpException('User not found');
} $view = $this->view($user, 200);
return $this->handleView($view);
Symfony как использовать FOSRestBundle