You are here

protected static function PartyPrimaryFields::cleanSources in Party 7

Clean up source information.

Calculate the 'all types' key for properties and removing empty data sets.

2 calls to PartyPrimaryFields::cleanSources()
PartyPrimaryFields::buildSources in includes/party.primary_fields.inc
Build the primary field source information.
PartyPrimaryFields::getSourcesByType in includes/party.primary_fields.inc
Get hold of primary field sources by type.

File

includes/party.primary_fields.inc, line 812
Primary field related functions and callbacks.

Class

PartyPrimaryFields
Helper class for primary fields.

Code

protected static function cleanSources(&$sources) {
  foreach ($sources as $data_set_name => &$data_set) {

    // Remove empty data sets.
    if (empty($data_set['sources'])) {
      unset($sources[$data_set_name]);
      continue;
    }

    // Build a list of all types including callbacks.
    foreach ($sources[$data_set_name]['sources'] as &$source) {

      // Make sure our basic type is included.
      $source['all types'][] = $source['type'];

      // Add any callback types.
      foreach ($source['callbacks'] as $callback) {
        $source['all types'][] = $callback['type'];
      }

      // Filter the list and map it.
      $source['all types'] = drupal_map_assoc(array_unique($source['all types']));
    }
  }
}