You are here

function commerce_braintree_enable in Commerce Braintree 7.2

Same name and namespace in other branches
  1. 7.3 commerce_braintree.install \commerce_braintree_enable()
  2. 7 commerce_braintree.install \commerce_braintree_enable()

Implements hook_enable().

File

./commerce_braintree.install, line 6

Code

function commerce_braintree_enable() {

  // If Card on File is already enabled, fetch its weight.
  $weight = db_select('system', 's')
    ->fields('s', array(
    'weight',
  ))
    ->condition('name', 'commerce_cardonfile', '=')
    ->execute()
    ->fetchField();

  // If it wasn't found, pick an arbitrary high weight.
  if ($weight === FALSE) {
    $weight = 1000;
  }
  db_update('system')
    ->fields(array(
    'weight' => $weight + 1,
  ))
    ->condition('type', 'module')
    ->condition('name', 'commerce_braintree')
    ->execute();
}