You are here

function synonyms_entity_type_load in Synonyms 7

Test if entity type is applicable for having synonyms.

Parameters

string $entity_type: Entity type to test

Return value

bool|string Whether the provided entity type is applicable for having synonyms. If it is applicable, the $entity_type input argument will be returned. Otherwise FALSE is returned

2 calls to synonyms_entity_type_load()
synonyms_entity_property_info in ./synonyms.module
Implements hook_entity_property_info().
synonyms_settings_overview in ./synonyms.pages.inc
Page menu callback for managing Synonyms settings of entity types.

File

./synonyms.module, line 1443
Provide synonyms feature for Drupal entities.

Code

function synonyms_entity_type_load($entity_type) {
  if (module_exists('synonyms_provider_property')) {

    // If this submodule is enabled, we get into infinite recursion. Moreover,
    // it is very likely all entity types will have at least 1 property on them,
    // so the synonyms_provider_property module will get at least 1 synonym for
    // every entity type. So it is quite safe assumption to say we accept about
    // any entity type.
    return $entity_type;
  }
  $bundles = synonyms_bundle_normalize($entity_type, array());
  foreach (synonyms_behaviors() as $behavior => $behavior_definition) {
    foreach ($bundles as $bundle) {
      $behavior_implementations = synonyms_behavior_implementation_info($entity_type, $bundle, $behavior);
      if (!empty($behavior_implementations)) {
        return $entity_type;
      }
    }
  }
  return FALSE;
}