Created
April 3, 2011 02:45
-
-
Save bangpound/900124 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
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