annotate vendor/chi-teck/drupal-code-generator/templates/d7/hook/field_load.twig @ 5:12f9dff5fda9
tip
Update to Drupal core 8.7.1
author |
Chris Cannam |
date |
Thu, 09 May 2019 15:34:47 +0100 |
parents |
c75dbcec494b |
children |
|
rev |
line source |
Chris@0
|
1 /**
|
Chris@0
|
2 * Implements hook_field_load().
|
Chris@0
|
3 */
|
Chris@0
|
4 function {{ machine_name }}_field_load($entity_type, $entities, $field, $instances, $langcode, &$items, $age) {
|
Chris@0
|
5 // Sample code from text.module: precompute sanitized strings so they are
|
Chris@0
|
6 // stored in the field cache.
|
Chris@0
|
7 foreach ($entities as $id => $entity) {
|
Chris@0
|
8 foreach ($items[$id] as $delta => $item) {
|
Chris@0
|
9 // Only process items with a cacheable format, the rest will be handled
|
Chris@0
|
10 // by formatters if needed.
|
Chris@0
|
11 if (empty($instances[$id]['settings']['text_processing']) || filter_format_allowcache($item['format'])) {
|
Chris@0
|
12 $items[$id][$delta]['safe_value'] = isset($item['value']) ? _text_sanitize($instances[$id], $langcode, $item, 'value') : '';
|
Chris@0
|
13 if ($field['type'] == 'text_with_summary') {
|
Chris@0
|
14 $items[$id][$delta]['safe_summary'] = isset($item['summary']) ? _text_sanitize($instances[$id], $langcode, $item, 'summary') : '';
|
Chris@0
|
15 }
|
Chris@0
|
16 }
|
Chris@0
|
17 }
|
Chris@0
|
18 }
|
Chris@0
|
19 }
|