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
Here used to be a rough prototype of an | |
implementation, which is now deprecated. | |
in favour of this: | |
https://www.symfony.fi/entry/sharing-state-in-a-symfony-hybrid-app-with-twig-react-etc | |
----- | |
Using this approach you can bootstrap a | |
React application on the server side using | |
PHP/Symfony so that your client application |
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 | |
$stateId = 3; | |
$stateService = $this->get('ezpublish.api.service.object_state'); | |
$contentService = $this->get('ezpublish.api.service.content'); | |
$contentInfo = $contentService->loadContentInfo(93); | |
$objectStateGroup = $stateService->loadObjectStateGroup(4); |
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
c78e3b0f3d9244ed8c6d1c29464bdff9 |
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 | |
/** | |
* @Route("/test",name="testroute") | |
* @Template | |
*/ | |
public function testAction(Request $request, Checkout $checkout) | |
{ | |
$repository = $this->get('ezpublish.api.repository'); |
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
cd /var/www/html/ezstudio/ | |
php app/console assets:install --symlink | |
php app/console assetic:dump --env=dev |
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
{{ render_esi( | |
controller( | |
"Foo:Default:bar", | |
{ | |
'bar': foo, | |
} | |
) | |
) }} |
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 | |
namespace AppBundle\State; | |
use Symfony\Component\Serializer\Serializer; | |
use Symfony\Component\Serializer\Encoder\JsonEncoder; | |
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer; | |
class AppState implements \JsonSerializable { | |
public $fetchMore = false; |
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); |
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
<h2>Hello from Twig</h2> | |
<table> | |
{% for apartment in appstate.apartments %} | |
<tr> | |
<td> | |
{{ apartment.streetaddress }}<br /> | |
{{ apartment.city }}<br /> | |
{{ apartment.zipcode }} | |
</td> | |
<td>{{ apartment.country }}</td> |
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
<script type="text/javascript"> | |
var initialAppState = {{ appstate_serialized|raw }}; | |
</script> | |
<script src="{{ asset('bundles/app/js/vue/vue.js') }}"></script> | |
<script src="{{ asset('bundles/app/js/vue/app.js') }}"></script> |