You are here

function entityreference_autofill_set_module_weight in Entity reference autofill 7

Relative module weight setter.

3 calls to entityreference_autofill_set_module_weight()
entityreference_autofill_install in ./entityreference_autofill.install
Implements hook_install().
entityreference_autofill_modules_enabled in ./entityreference_autofill.install
Implements hook_modules_enabled().
entityreference_autofill_update_7000 in ./entityreference_autofill.install
Update module weight to give prepopulate priority.

File

./entityreference_autofill.install, line 29
Install and update functions for the Entity reference autofill module.

Code

function entityreference_autofill_set_module_weight() {
  if (module_exists('entityreference_prepopulate')) {

    // Get weight of entityreference_prepopulate.
    $weight = db_select('system', 's')
      ->fields('s', array(
      'weight',
    ))
      ->condition('name', 'entityreference_prepopulate', '=')
      ->execute()
      ->fetchField();

    // Set this module's weight one higher.
    db_update('system')
      ->fields(array(
      'weight' => $weight + 1,
    ))
      ->condition('name', 'entityreference_autofill', '=')
      ->execute();
  }
}