You are here

public static function PartyPrimaryFields::sourceTypeMatch in Party 7

Check whether the types match.

Parameters

string|array $types: Either a single type or an array of types we want suitable sources for.

array $source: The source info for the source we are checking. See PartyPrimaryFields::$sources for the data structure.

bool $all_types: Indicate whether you want to check against the 'all types' key which includes callback types. Defaults to TRUE.

Return value

bool Whether the source matches the given type(s).

1 call to PartyPrimaryFields::sourceTypeMatch()
PartyPrimaryFields::getSourcesByType in includes/party.primary_fields.inc
Get hold of primary field sources by type.

File

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

Class

PartyPrimaryFields
Helper class for primary fields.

Code

public static function sourceTypeMatch($types, $source, $all_types = TRUE) {

  // Make sure $types is an array.
  $types = (array) $types;

  // If $all_types we want to check the 'all types' key which is an array.
  if ($all_types) {
    return (bool) array_intersect($types, $source['all types']);
  }
  else {
    return in_array($source['type'], $types);
  }
}