You are here

function hook_synonyms_behavior_implementation_info in Synonyms 7

Collect info about available synonyms behavior implementations.

If your module ships a synonyms behavior implementation you probably want to implement this hook. However, exercise caution, if your synonyms behavior implementation is a field-based one, you might be better off implementing hook_synonyms_field_behavior_implementation_info().

Parameters

string $entity_type: Entity type whose synonyms behavior implementations are requested

string $bundle: Bundle name whose synonyms behavior implementations are requested

string $behavior: Behavior name whose implementations are requested

Return value

array Array of information about synonyms behavior implementations your module exposes. Each sub array will represent a single synonyms behavior implementation and should have the following structure:

  • provider: (string) machine name of your synonyms behavior implementation. Prefix it with your module name to make sure no name collision happens. Also, provider must be unique within the namespace of behavior, entity type and bundle. Basically, this is what distinguishes one behavior implementation from another
  • label: (string) Human friendly translated name of your synonyms behavior implementation
  • class: (string) Name of PHP class that implements synonyms behavior interface, which is stated in synonyms behavior definition. This class will do all the synonyms work. This hook serves pure declarative function to map entity types, bundles with their synonym behavior implementations whereas real "synonyms-related" work is implemented in your class
2 functions implement hook_synonyms_behavior_implementation_info()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

synonyms_provider_field_synonyms_behavior_implementation_info in synonyms_provider_field/synonyms_provider_field.module
Implements hook_synonyms_provider_info().
synonyms_provider_property_synonyms_behavior_implementation_info in synonyms_provider_property/synonyms_provider_property.module
Implements hook_synonyms_behavior_implementation_info().
1 invocation of hook_synonyms_behavior_implementation_info()
synonyms_behavior_implementation_info in ./synonyms.module
Collect info on available synonyms behavior implementations.

File

./synonyms.api.php, line 40
Documentation for Synonyms module.

Code

function hook_synonyms_behavior_implementation_info($entity_type, $bundle, $behavior) {
  $providers = array();
  switch ($entity_type) {
    case 'entity_type_i_want':
      switch ($bundle) {
        case 'bundle_i_want':
          switch ($behavior) {
            case 'behavior_i_want':
              $providers[] = array(
                'provider' => 'my_module_synonyms_behavior_implementation_machine_name',
                'label' => t('This is human friendly name of my synonyms behavior implementation. Put something meaningful here'),
                'class' => 'MySynonymsSynonymsBehavior',
              );
              break;
          }
          break;
      }
      break;
  }
  return $providers;
}