Entity-Translations =================== Updated Controller """""""""""""""""" Add parameter ``$locale`` to editAction and showAction: .. code-block:: php public function updateAction(Request $request, $id, $locale) public function editAction($id, $locale) edit the "change"-URL in the Update-Form: .. code-block:: php 'action' => $this->generateUrl('...', array( 'id' => $entity->getId(), 'locale' => $entity->getTranslatableLocale() )), Set **locale** in editAction() and updateAction(): .. code-block:: php $entity = $em->getRepository('tpointProjectBundle:CostCentre')->find($id); $entity->setTranslatableLocale($locale); $em->refresh($entity); Show-Action: get all languages and translations .. code-block:: php $entity = $em->getRepository('...')->find($id); $repository = $em->getRepository('Gedmo\Translatable\Entity\Translation'); $translations = $repository->findTranslations($entity); if (!$entity) { throw $this->createNotFoundException('Unable to find CostCentre entity.'); } $languages = $em->getRepository('tpointContactBundle:Language')->findTransLangs(); $deleteForm = $this->createDeleteForm($id); return $this->render('tpointProjectBundle:CostCentre:show.html.twig', array( 'entity' => $entity, 'delete_form' => $deleteForm->createView(), 'translations' => $translations, 'languages' => $languages )); Update Entity """"""""""""" Add the method `getTranslatableLocale()` muss vorhanden sein: .. code-block:: php public function getTranslatableLocale() { return $this->locale; } Update Routing """""""""""""" Edit the ``.._edit`` and ``.._update`` routes (additional parameter: locale) .. code-block:: yaml tpoint_admin_costcentre_edit: pattern: /{id}/{locale}/edit defaults: { _controller: "tpointProjectBundle:CostCentre:edit", id:0, locale:en } tpoint_admin_costcentre_update: pattern: /{id}/{locale}/update defaults: { _controller: "tpointProjectBundle:CostCentre:update", id:0, locale:en } requirements: { _method: post|put } Update View (show.html.twig) """""""""""""""""""""""""""" **List all avaliable Languages** .. code-block:: html Id {{ entity.id }} {% for key,lang in translations %} Label {{key}}: {{ lang.label }} edit {% endfor %} **add Language-Buttons** (all Languages) .. code-block:: html
{% for lang in languages %} edit {{lang.code}} {% endfor%}