function pm_field_instances_create_if_required in Drupal PM (Project Management) 7.3
Same name and namespace in other branches
- 8 includes/pm.field.inc \pm_field_instances_create_if_required()
- 7.2 includes/pm.field.inc \pm_field_instances_create_if_required()
Iterate through an array of field instances, creating if not present.
Parameters
array $field_instances: Array of field bases to check.
Return value
array $result Array of success / failure flags.
10 calls to pm_field_instances_create_if_required()
- pmexpense_migrate_create_fields in pmexpense/
includes/ pmexpense.migrate.inc - Creates and attaches fields to Drupal user.
- pmissue_migrate_create_fields in pmissue/
includes/ pmissue.migrate.inc - Creates and attaches fields to Drupal user.
- pmnote_migrate_create_fields in pmnote/
includes/ pmnote.migrate.inc - Creates and attaches fields to Drupal user.
- pmorganization_migrate_create_fields in pmorganization/
includes/ pmorganization.migrate.inc - Creates and attaches fields to Drupal user.
- pmperson_migrate_create_fields in pmperson/
includes/ pmperson.migrate.inc - Creates and attaches fields to Drupal user.
File
- includes/
pm.field.inc, line 94 - Field creation functions.
Code
function pm_field_instances_create_if_required(array $field_instances) {
$result = array();
if (!empty($field_instances) and is_array($field_instances)) {
foreach ($field_instances as $key => $field_instance) {
$field_name = $field_instance['field_name'];
$result[$key] = pm_field_instance_create_if_required($field_name, $field_instance);
}
}
foreach ($result as $key => $status) {
$variables = array(
'@field_name' => $field_instances[$key]['field_name'],
);
switch ($status) {
case PM_FIELD_INSTANCE_CREATE_FAILURE:
$message = 'Failed to create field instance - @field_name';
watchdog('pm', $message, $variables, WATCHDOG_ERROR);
throw new Exception("Drupal PM: Error Creating field instance - " . $field_instances[$key]['field_name'] . ' (' . $key . ')', 1);
case PM_FIELD_INSTANCE_CREATE_SUCCESS:
$message = 'Successfully created field instance - @field_name';
watchdog('pm', $message, $variables, WATCHDOG_INFO);
break;
case PM_FIELD_INSTANCE_UPDATE_SUCCESS:
$message = 'Successfully Updated field instance - @field_name';
watchdog('pm', $message, $variables, WATCHDOG_INFO);
break;
}
}
return $result;
}