function paragraphs_field_is_empty in Paragraphs 7
Implements hook_field_is_empty().
File
- ./
paragraphs.module, line 862 - Paragraphs hooks and common functions.
Code
function paragraphs_field_is_empty($item, $field) {
// Item is empty when we removed it.
if (isset($item['entity']) && (isset($item['entity']->removed) && $item['entity']->removed || isset($item['entity']->confirmed_removed) && $item['entity']->confirmed_removed)) {
return TRUE;
}
if (!empty($item['value'])) {
return FALSE;
}
elseif (isset($item['entity']) && ($instances = field_info_instances('paragraphs_item', $item['entity']->bundle)) && !empty($instances)) {
// With a valid instance we can re-use the "field is empty" hook.
return paragraphs_item_is_empty($item['entity']);
}
elseif (isset($item['entity'])) {
// Because of hook_entity_view_alter, the content comes from a view but not
// stored in a field.
return FALSE;
}
return TRUE;
}