You are here

commerce_paypal.install in Commerce PayPal 8

Same filename and directory in other branches
  1. 7.2 commerce_paypal.install
  2. 7 commerce_paypal.install

Contains install and update functions for Commerce PayPal.

File

commerce_paypal.install
View source
<?php

/**
 * @file
 * Contains install and update functions for Commerce PayPal.
 */

/**
 * Install the PayPal Checkout payment method type.
 */
function commerce_paypal_update_8101() {
  $entity_type = \Drupal::entityTypeManager()
    ->getDefinition('commerce_payment_method');
  \Drupal::service('entity.bundle_plugin_installer')
    ->installBundles($entity_type, [
    'commerce_paypal',
  ]);
}

/**
 * Install the PayPal Checkout payment method type.
 */
function commerce_paypal_update_8102() {
  $entity_type = \Drupal::entityTypeManager()
    ->getDefinition('commerce_payment_method');
  \Drupal::service('entity.bundle_plugin_installer')
    ->installBundles($entity_type, [
    'commerce_paypal',
  ]);
}

/**
 * Move the credit messaging settings to a different config object.
 */
function commerce_paypal_update_8103() {
  $config_factory = \Drupal::configFactory();
  $legacy_config = $config_factory
    ->getEditable('commerce_paypal.settings');
  $client_id = $legacy_config
    ->get('commerce_paypal.credit_messaging_client_id');
  if ($client_id) {
    $config = $config_factory
      ->getEditable('commerce_paypal.credit_messaging_settings');
    $config
      ->set('client_id', $client_id)
      ->set('add_to_cart', $legacy_config
      ->get('commerce_paypal.credit_messaging_add_to_cart'))
      ->save();
    $legacy_config
      ->delete();
  }
}

Functions

Namesort descending Description
commerce_paypal_update_8101 Install the PayPal Checkout payment method type.
commerce_paypal_update_8102 Install the PayPal Checkout payment method type.
commerce_paypal_update_8103 Move the credit messaging settings to a different config object.