Skip to content

Instantly share code, notes, and snippets.

@AD7six
Forked from lorenzo/translation_formatter.php
Last active December 30, 2015 00:09
Show Gist options
  • Save AD7six/7747612 to your computer and use it in GitHub Desktop.
Save AD7six/7747612 to your computer and use it in GitHub Desktop.
<?php
$formatter = function($entity) use ($preferredlanguage, $translatedFields) {
foreach ($entity->translations as $translation) {
if ($translation->locale === $preferredlanguage) {
$field = $translation->get('field');
$value = $translation->get('value');
$entity->set($field, $value);
}
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment