You are here

function synonyms_behavior_settings_unpack in Synonyms 7

Execute unpacking on the just loaded synonyms behavior implementations.

Parameters

array $behavior_implementations: Array of the just loaded behavior_implementations. Each sub array should contain the following keys:

  • entity_type: (string) Entity type that corresponds to this behavior implementation
  • bundle: (string) Bundle that corresponds to this behavior implementation
  • provider: (string) Machine name of this synonyms behavior implementation
  • behavior: (string) name of the synonyms behavior to which these settings apply
  • settings_serialized: (string) serialized content of the settings

Return value

array Unpacked version of the provided $settings

2 calls to synonyms_behavior_settings_unpack()
synonyms_behavior_get in ./synonyms.module
Load function for existing implementations of synonyms behaviors.
synonyms_behavior_get_all_enabled in ./synonyms.module
Load all enabled behavior implementations on an entity_type and a bundle.

File

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

Code

function synonyms_behavior_settings_unpack($behavior_implementations) {

  // Array of previously queried synonyms provider info.
  $cache = array();
  foreach ($behavior_implementations as &$behavior_implementation) {
    if (!isset($cache[$behavior_implementation['behavior']][$behavior_implementation['entity_type']][$behavior_implementation['bundle']])) {
      $cache[$behavior_implementation['behavior']][$behavior_implementation['entity_type']][$behavior_implementation['bundle']] = synonyms_behavior_implementation_info($behavior_implementation['entity_type'], $behavior_implementation['bundle'], $behavior_implementation['behavior']);
    }

    // Behavior implementation info may be not available in some rare extreme
    // cases. For example, when a field instance is being deleted.
    if (isset($cache[$behavior_implementation['behavior']][$behavior_implementation['entity_type']][$behavior_implementation['bundle']][$behavior_implementation['provider']])) {
      $behavior_implementation += $cache[$behavior_implementation['behavior']][$behavior_implementation['entity_type']][$behavior_implementation['bundle']][$behavior_implementation['provider']];
    }
    if (isset($behavior_implementation['settings_serialized'])) {
      $behavior_implementation['settings'] = unserialize($behavior_implementation['settings_serialized']);
      if (isset($behavior_implementation['class'])) {
        $class = $behavior_implementation['class'];
        $behavior_implementation['object'] = new $class($behavior_implementation);
      }
    }
  }
  unset($behavior_implementation);
  return $behavior_implementations;
}