You are here

function pm_field_bases_create_if_required in Drupal PM (Project Management) 7.3

Same name and namespace in other branches
  1. 8 includes/pm.field.inc \pm_field_bases_create_if_required()
  2. 7.2 includes/pm.field.inc \pm_field_bases_create_if_required()

Iterate through an array of field bases, creating if not present.

Parameters

array $field_bases: Array of field bases to check.

Return value

array $result Array of success / failure flags.

10 calls to pm_field_bases_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.

... See full list

File

includes/pm.field.inc, line 24
Field creation functions.

Code

function pm_field_bases_create_if_required(array $field_bases) {
  $result = array();
  if (!empty($field_bases) and is_array($field_bases)) {
    foreach ($field_bases as $key => $field_base) {
      $field_name = $field_base['field_name'];
      $result[$key] = pm_field_base_create_if_required($field_name, $field_base);
    }
  }
  foreach ($result as $key => $status) {
    $variables = array(
      '@field_name' => $field_bases[$key]['field_name'],
    );
    switch ($status) {
      case PM_FIELD_BASE_CREATE_FAILURE:
        $message = 'Failed to create field base - @field_name';
        watchdog('pm', $message, $variables, WATCHDOG_ERROR);
        throw new Exception("Drupal PM: Error Creating field base - " . $field_bases[$key]['field_name'], 1);
      case PM_FIELD_BASE_CREATE_SUCCESS:
        $message = 'Successfully created field base - @field_name';
        watchdog('pm', $message, $variables, WATCHDOG_INFO);
        break;
      case PM_FIELD_BASE_UPDATE_SUCCESS:
        $message = 'Successfully Updated field base - @field_name';
        watchdog('pm', $message, $variables, WATCHDOG_INFO);
        break;
    }
  }
  return $result;
}