Created
January 25, 2017 19:22
-
-
Save janit/c38430a3fd2e8989e0856f8c78d6a0fc to your computer and use it in GitHub Desktop.
DefaultController.php from https://www.symfony.fi/entry/sharing-state-in-a-symfony-hybrid-app-with-twig-react-etc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function indexAction(Request $request ) | |
{ | |
$appState = new AppState(); | |
$em = $this->get('doctrine.orm.default_entity_manager'); | |
$apartments = $em->getRepository('AppBundle:Apartment')->findByLimit(3); | |
$appState->setApartments($apartments); | |
$appState->setFetchMore(true); | |
return $this->render('default/index.html.twig', [ | |
'appstate' => $appState, | |
'appstate_serialized' => $appState->jsonSerialize() | |
]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment