diff --git a/mappers/entity_translation.inc b/mappers/entity_translation.inc index 2ea5abc..eec9e5e 100644 --- a/mappers/entity_translation.inc +++ b/mappers/entity_translation.inc @@ -28,12 +28,13 @@ function entity_translation_feeds_presave(FeedsSource $source, $entity, $item, $ $field_name = $instance['field_name']; // No values in this field, skip it. - if (empty($entity->$field_name)) { + if (empty($entity->$field_name) || !is_array($entity->$field_name)) { continue; } // Not translatable. - if (($info = field_info_field($field_name)) && !$info['translatable']) { + $info = field_info_field($field_name); + if (!$info || !$info['translatable']) { continue; } diff --git a/mappers/locale.inc b/mappers/locale.inc index 4d18dcc..d23ad93 100644 --- a/mappers/locale.inc +++ b/mappers/locale.inc @@ -16,6 +16,9 @@ function locale_feeds_processor_targets_alter(array &$targets, $entity_type, $bu } } +/** + * Preprocess callback that set's the configured mapping language. + */ function locale_feeds_preprocess_callback(FeedsSource $source, $target_item, array $target, array &$mapping) { if (empty($mapping['field_language'])) { return; @@ -24,6 +27,9 @@ function locale_feeds_preprocess_callback(FeedsSource $source, $target_item, arr $mapping['language'] = $mapping['field_language']; } +/** + * Summary callback. + */ function locale_feeds_summary_callback(array $mapping, array $target, array $form, array $form_state) { $entity_type = $form_state['build_info']['args'][0]->processor->entityType(); $translatable = _locale_feeds_target_is_translatable($entity_type, $mapping['target']); @@ -48,6 +54,9 @@ function locale_feeds_summary_callback(array $mapping, array $target, array $for return t('Language: %lang', array('%lang' => $language_options[$mapping['field_language']])); } +/** + * Form callback. + */ function locale_feeds_form_callback(array $mapping, array $target, array $form, array $form_state) { $form = array(); @@ -81,6 +90,17 @@ function locale_feeds_form_callback(array $mapping, array $target, array $form, return $form; } +/** + * Determines if a target is translatable. + * + * @param string $entity_type + * The entity type. + * @param string $target + * The target. + * + * @return bool + * Returns true if the target is translatable, false if not. + */ function _locale_feeds_target_is_translatable($entity_type, $target) { list($field_name) = explode(':', $target, 2); diff --git a/tests/feeds_mapper_multilingual_fields.test b/tests/feeds_mapper_multilingual_fields.test index 3620c31..99bf0a1 100644 --- a/tests/feeds_mapper_multilingual_fields.test +++ b/tests/feeds_mapper_multilingual_fields.test @@ -188,7 +188,7 @@ class FeedsMapperMultilingualFieldsTestCase extends FeedsMapperTestCase { /** * Configures Drupal to be multilingual. */ - public function setupMultilingual($typename) { + protected function setupMultilingual($typename) { // Setup Other Language (french). $edit = array( 'langcode' => 'fr',