On this page
function field_system_info_alter
field_system_info_alter(&$info, $file, $type)
Implements hook_system_info_alter().
Goes through a list of all modules that provide a field type, and makes them required if there are any active fields of that type.
Related topics
File
- modules/field/field.module, line 366
- Attach custom data fields to Drupal entities.
Code
function field_system_info_alter(&$info, $file, $type) {
if ($type == 'module' && module_hook($file->name, 'field_info')) {
$fields = field_read_fields(array('module' => $file->name), array('include_deleted' => TRUE));
if ($fields) {
$info['required'] = TRUE;
// Provide an explanation message (only mention pending deletions if there
// remains no actual, non-deleted fields)
$non_deleted = FALSE;
foreach ($fields as $field) {
if (empty($field['deleted'])) {
$non_deleted = TRUE;
break;
}
}
if ($non_deleted) {
if (module_exists('field_ui')) {
$explanation = t('Field type(s) in use - see <a href="@fields-page">Field list</a>', array('@fields-page' => url('admin/reports/fields')));
}
else {
$explanation = t('Fields type(s) in use');
}
}
else {
$explanation = t('Fields pending deletion');
}
$info['explanation'] = $explanation;
}
}
}
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!field!field.module/function/field_system_info_alter/7.x