Skip to content
This repository has been archived by the owner on Jan 5, 2018. It is now read-only.

Issue #2721665 by alexsergivan: Fixed entity browser for multilingual content #150

Open
wants to merge 2 commits into
base: 8.x-1.x
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/Controllers/EntityBrowserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ class EntityBrowserController extends ControllerBase {
* containing the edit form.
*/
public function entityBrowserEdit(EntityInterface $entity) {
// Load the right translation for referenced entity if it's exists
// or create new translation if it does not exists.
if ($entity->isTranslatable()) {
$language = $this->languageManager()->getCurrentLanguage()->getId();
$entity = $entity->hasTranslation($language) ? $entity->getTranslation($language) : $entity->addTranslation($language, $entity->toArray());
}
// Build the entity edit form.
$form_object = $this->entityManager()->getFormObject($entity->getEntityTypeId(), 'edit');
$form_object->setEntity($entity);
Expand Down