Skip to content

Instantly share code, notes, and snippets.

@janit
Created January 25, 2017 21:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save janit/c2b364c14651c5613884509501052e96 to your computer and use it in GitHub Desktop.
Save janit/c2b364c14651c5613884509501052e96 to your computer and use it in GitHub Desktop.
public function apiApartmentsAction(Request $request)
{
$appState = new AppState();
$em = $this->get('doctrine.orm.default_entity_manager');
$apartments = $em->getRepository('AppBundle:Apartment')->getRandom(10);
$appState->setApartments($apartments);
$response = new JsonResponse();
$response->setContent($appState->jsonSerialize());
return $response;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment