You are here

salesforce_push.install in Salesforce Suite 5.0.x

Salesforce push install.

File

modules/salesforce_push/salesforce_push.install
View source
<?php

/**
 * @file
 * Salesforce push install.
 */
use Drupal\salesforce_push\PushQueue;

/**
 * Implements hook_install().
 */
function salesforce_push_install() {
  \Drupal::state()
    ->set('salesforce.push_queue_processor', PushQueue::DEFAULT_QUEUE_PROCESSOR);
  \Drupal::state()
    ->set('salesforce.push_queue_max_fails', PushQueue::DEFAULT_MAX_FAILS);
}

/**
 * Implements hook_uninstall().
 */
function salesforce_push_uninstall() {
  $delete = [
    'salesforce.push_queue_processor',
    'salesforce.push_queue_max_fails',
    'salesforce.mapping_push_info',
  ];
  \Drupal::state()
    ->deleteMultiple($delete);
  \Drupal::service('queue.salesforce_push')
    ->deleteTable();
}

/**
 * Set default variables for push queue.
 */
function salesforce_push_update_8001() {
  if (\Drupal::state()
    ->get('salesforce.push_queue_processor', FALSE) === FALSE) {
    \Drupal::state()
      ->set('salesforce.push_queue_processor', PushQueue::DEFAULT_QUEUE_PROCESSOR);
  }
  if (\Drupal::state()
    ->get('salesforce.push_queue_max_fails', FALSE) === FALSE) {
    \Drupal::state()
      ->set('salesforce.push_queue_max_fails', PushQueue::DEFAULT_MAX_FAILS);
  }
}

/**
 * Create new variables for more granualar push limits.
 */
function salesforce_push_update_8002() {
  if (\Drupal::state()
    ->get('salesforce.global_push_limit', FALSE) === FALSE) {
    \Drupal::state()
      ->set('salesforce.global_push_limit', PushQueue::DEFAULT_GLOBAL_LIMIT);
  }
  \Drupal::state()
    ->delete('salesforce.push_limit');
}

/**
 * Moves global push limit out of state into config.
 */
function salesforce_push_update_8003() {
  $config = \Drupal::configFactory()
    ->getEditable('salesforce.settings');
  if ($config
    ->get('global_push_limit') === NULL) {
    $config
      ->set('global_push_limit', \Drupal::state()
      ->get('salesforce.global_push_limit', PushQueue::DEFAULT_GLOBAL_LIMIT))
      ->save();
  }
  \Drupal::state()
    ->delete('salesforce.global_push_limit');
}

Functions

Namesort descending Description
salesforce_push_install Implements hook_install().
salesforce_push_uninstall Implements hook_uninstall().
salesforce_push_update_8001 Set default variables for push queue.
salesforce_push_update_8002 Create new variables for more granualar push limits.
salesforce_push_update_8003 Moves global push limit out of state into config.