commerce_paypal-8.x-1.0-beta11/commerce_paypal.install

commerce_paypal.install
<?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();
  }
}

/**
 * Disables credit card icon settings on existing payment gateways.
 */
function commerce_paypal_update_8104() {
  $payment_gateways = \Drupal::entityTypeManager()
    ->getStorage('commerce_payment_gateway')
    ->loadMultiple();

  foreach ($payment_gateways as $payment_gateway) {
    if ($payment_gateway->getPluginId() !== 'paypal_checkout') {
      continue;
    }
    $configuration = $payment_gateway->getPluginConfiguration();
    $configuration['enable_credit_card_icons'] = FALSE;
    $payment_gateway->setPluginConfiguration($configuration);
    $payment_gateway->save();
  }
}

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

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc