You are here

function commerce_registration_get_entity_settings in Commerce Registration 7.3

Returns the entity settings for the given entity.

2 calls to commerce_registration_get_entity_settings()
commerce_registration_form_node_form_alter in ./commerce_registration.module
Implements hook_form_FORM_ID_alter().
commerce_registration_hide_tab in ./commerce_registration.module
Check if the node has set to hide the manage registrations tab.

File

./commerce_registration.module, line 437
Commerce Registration module code.

Code

function commerce_registration_get_entity_settings($entity_type, $entity, $reset = FALSE) {
  $settings =& drupal_static(__FUNCTION__, NULL, $reset);
  list($entity_id, , $bundle) = entity_extract_ids($entity_type, $entity);
  if (!isset($settings[$entity_type][$entity_id]) || $reset) {
    $default_settings = module_invoke_all('commerce_registration_entity_default_settings', $entity_type, $entity);
    $db_settings = db_select('commerce_registration_settings', 'crs')
      ->fields('crs', array(
      'settings',
    ))
      ->condition('entity_type', $entity_type)
      ->condition('entity_id', $entity_id)
      ->condition('entity_bundle', $bundle)
      ->execute()
      ->fetchCol();
    if (!empty($db_settings)) {
      $db_settings = $db_settings[0];
      if (!is_array($db_settings)) {
        $db_settings = unserialize($db_settings);
      }
    }
    else {
      $db_settings = array();
    }
    $settings[$entity_type][$entity_id] = array_unique(array_merge($default_settings, $db_settings));
  }
  return $settings[$entity_type][$entity_id];
}