X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fchi-teck%2Fdrupal-code-generator%2Ftemplates%2Fd7%2Fhook%2Ffield_load.twig;fp=vendor%2Fchi-teck%2Fdrupal-code-generator%2Ftemplates%2Fd7%2Fhook%2Ffield_load.twig;h=c5d1a1dd8337e70db000c6036426afce69d91905;hp=0000000000000000000000000000000000000000;hb=af6d1fb995500ae68849458ee10d66abbdcfb252;hpb=680c79a86e3ed402f263faeac92e89fb6d9edcc0 diff --git a/vendor/chi-teck/drupal-code-generator/templates/d7/hook/field_load.twig b/vendor/chi-teck/drupal-code-generator/templates/d7/hook/field_load.twig new file mode 100644 index 000000000..c5d1a1dd8 --- /dev/null +++ b/vendor/chi-teck/drupal-code-generator/templates/d7/hook/field_load.twig @@ -0,0 +1,19 @@ +/** + * Implements hook_field_load(). + */ +function {{ machine_name }}_field_load($entity_type, $entities, $field, $instances, $langcode, &$items, $age) { + // Sample code from text.module: precompute sanitized strings so they are + // stored in the field cache. + foreach ($entities as $id => $entity) { + foreach ($items[$id] as $delta => $item) { + // Only process items with a cacheable format, the rest will be handled + // by formatters if needed. + if (empty($instances[$id]['settings']['text_processing']) || filter_format_allowcache($item['format'])) { + $items[$id][$delta]['safe_value'] = isset($item['value']) ? _text_sanitize($instances[$id], $langcode, $item, 'value') : ''; + if ($field['type'] == 'text_with_summary') { + $items[$id][$delta]['safe_summary'] = isset($item['summary']) ? _text_sanitize($instances[$id], $langcode, $item, 'summary') : ''; + } + } + } + } +}