Skip to content

Instantly share code, notes, and snippets.

@bangpound
Created April 3, 2011 02:45
Show Gist options
  • Save bangpound/900124 to your computer and use it in GitHub Desktop.
Save bangpound/900124 to your computer and use it in GitHub Desktop.
<?php
abstract class MigrateFieldHandler extends MigrateHandler {
// abstract function arguments(...)
abstract public function prepare(stdClass $entity, array $field_info, array $instance, array $values);
/**
* Determine the language of the field
*
* @param $entity
* @param $field_info
* @param $arguments
* @return string language code
*/
function getFieldLanguage(stdClass $entity, $field_info, array $arguments) {
$migration = Migration::currentMigration();
switch (TRUE) {
case !field_is_translatable($migration->getDestination()->getEntityType(), $field_info):
return LANGUAGE_NONE;
case isset($arguments['language']):
return $arguments['language'];
case $entity->language != LANGUAGE_NONE:
return $entity->language;
break;
default:
return $migration->getDestination()->getLanguage();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment