Pull merge.
[yaffs-website] / vendor / chi-teck / drupal-code-generator / templates / d7 / hook / field_load.twig
1 /**
2  * Implements hook_field_load().
3  */
4 function {{ machine_name }}_field_load($entity_type, $entities, $field, $instances, $langcode, &$items, $age) {
5   // Sample code from text.module: precompute sanitized strings so they are
6   // stored in the field cache.
7   foreach ($entities as $id => $entity) {
8     foreach ($items[$id] as $delta => $item) {
9       // Only process items with a cacheable format, the rest will be handled
10       // by formatters if needed.
11       if (empty($instances[$id]['settings']['text_processing']) || filter_format_allowcache($item['format'])) {
12         $items[$id][$delta]['safe_value'] = isset($item['value']) ? _text_sanitize($instances[$id], $langcode, $item, 'value') : '';
13         if ($field['type'] == 'text_with_summary') {
14           $items[$id][$delta]['safe_summary'] = isset($item['summary']) ? _text_sanitize($instances[$id], $langcode, $item, 'summary') : '';
15         }
16       }
17     }
18   }
19 }