Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / chi-teck / drupal-code-generator / templates / d7 / hook / field_prepare_translation.twig
diff --git a/vendor/chi-teck/drupal-code-generator/templates/d7/hook/field_prepare_translation.twig b/vendor/chi-teck/drupal-code-generator/templates/d7/hook/field_prepare_translation.twig
new file mode 100644 (file)
index 0000000..6eacc51
--- /dev/null
@@ -0,0 +1,13 @@
+/**
+ * Implements hook_field_prepare_translation().
+ */
+function {{ machine_name }}_field_prepare_translation($entity_type, $entity, $field, $instance, $langcode, &$items, $source_entity, $source_langcode) {
+  // If the translating user is not permitted to use the assigned text format,
+  // we must not expose the source values.
+  $field_name = $field['field_name'];
+  $formats = filter_formats();
+  $format_id = $source_entity->{$field_name}[$source_langcode][0]['format'];
+  if (!filter_access($formats[$format_id])) {
+    $items = array();
+  }
+}