Browse Source

Avoid attempting to refer to an unknown index. (#876)

When running in a bare site (without any content... like, in a unit
testing rig), this ends up trying to refer to a non-existent offset.

... add an `isset()` test to avoid doing so.
pull/883/head
Adam 3 years ago committed by GitHub
parent
commit
3d122af5d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 17
      islandora.views.inc

17
islandora.views.inc

@ -13,13 +13,16 @@ function islandora_views_data_alter(&$data) {
$fields = \Drupal::service('entity_field.manager')->getFieldStorageDefinitions('node'); $fields = \Drupal::service('entity_field.manager')->getFieldStorageDefinitions('node');
foreach ($fields as $field => $field_storage_definition) { foreach ($fields as $field => $field_storage_definition) {
if ($field_storage_definition->getType() == 'integer' && strpos($field, "field_") === 0) { if ($field_storage_definition->getType() == 'integer' && strpos($field, "field_") === 0) {
$data['node__' . $field][$field . '_value']['field'] = $data['node__' . $field][$field]['field']; $prefixed_field = 'node__' . $field;
$data['node__' . $field][$field]['title'] = t('Integer Weight Selector (@field)', [ if (isset($data[$prefixed_field])) {
'@field' => $field, $data[$prefixed_field][$field . '_value']['field'] = $data[$prefixed_field][$field]['field'];
]); $data[$prefixed_field][$field]['title'] = t('Integer Weight Selector (@field)', [
$data['node__' . $field][$field]['help'] = t('Provides a drag-n-drop reordering of integer-based weight fields.'); '@field' => $field,
$data['node__' . $field][$field]['title short'] = t('Integer weight selector'); ]);
$data['node__' . $field][$field]['field']['id'] = 'integer_weight_selector'; $data[$prefixed_field][$field]['help'] = t('Provides a drag-n-drop reordering of integer-based weight fields.');
$data[$prefixed_field][$field]['title short'] = t('Integer weight selector');
$data[$prefixed_field][$field]['field']['id'] = 'integer_weight_selector';
}
} }
} }
} }

Loading…
Cancel
Save