You are here

function synonyms_behavior_implementation_save in Synonyms 7

Save the provided synonyms behavior implementation into the database.

Parameters

array $behavior_implementation: Behavior implementation array, such as one from synonyms_behavior_get() or alike

9 calls to synonyms_behavior_implementation_save()
AbstractAutocompleteSynonymsWebTestCase::setUp in ./synonyms.test
SetUp method.
AbstractAutocompleteSynonymsWebTestCase::testAutocompleteMenuPath in ./synonyms.test
Test autocomplete menu path.
SynonymsProviderPropertyWebTestCase::setUp in synonyms_provider_property/synonyms_provider_property.test
SetUp method.
SynonymsSynonymsWebTestCase::testSynonyms in ./synonyms.test
Test the functionality of synonyms.
SynonymsWebTestCase::setUp in ./synonyms.test
SetUp method.

... See full list

File

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

Code

function synonyms_behavior_implementation_save($behavior_implementation) {
  if (!isset($behavior_implementation['settings'])) {
    $behavior_implementation['settings'] = array();
  }
  $behavior_implementation['settings_serialized'] = serialize($behavior_implementation['settings']);
  $result = db_merge('synonyms_settings')
    ->key(array(
    'entity_type' => $behavior_implementation['entity_type'],
    'bundle' => $behavior_implementation['bundle'],
    'provider' => $behavior_implementation['provider'],
    'behavior' => $behavior_implementation['behavior'],
  ))
    ->fields(array(
    'entity_type' => $behavior_implementation['entity_type'],
    'bundle' => $behavior_implementation['bundle'],
    'provider' => $behavior_implementation['provider'],
    'behavior' => $behavior_implementation['behavior'],
    'settings_serialized' => $behavior_implementation['settings_serialized'],
  ))
    ->execute();
  switch ($result) {
    case MergeQuery::STATUS_INSERT:
      $behavior_definition = synonyms_behaviors();
      $behavior_definition = $behavior_definition[$behavior_implementation['behavior']];
      $enabled_callback = ctools_plugin_get_function($behavior_definition, 'enabled callback');
      if ($enabled_callback) {
        $enabled_callback($behavior_definition, $behavior_implementation);
      }
      break;
  }
}