You are here

private function UPS::preparePluginDefinition in Commerce UPS 8.3

Prepares the service array keys to support integer values.

See https://www.drupal.org/node/2904467 for more information.

TODO: Remove once core issue has been addressed.

Parameters

array $plugin_definition: The plugin definition provided to the class.

Return value

array The prepared plugin definition.

1 call to UPS::preparePluginDefinition()
UPS::__construct in src/Plugin/Commerce/ShippingMethod/UPS.php
Constructs a new UPS object.

File

src/Plugin/Commerce/ShippingMethod/UPS.php, line 100

Class

UPS
Provides the UPS shipping method.

Namespace

Drupal\commerce_ups\Plugin\Commerce\ShippingMethod

Code

private function preparePluginDefinition(array $plugin_definition) {

  // Cache and unset the parsed plugin definitions for services.
  $services = $plugin_definition['services'];
  unset($plugin_definition['services']);

  // Loop over each service definition and redefine them with
  // integer keys that match the UPS API.
  foreach ($services as $key => $service) {

    // Remove the "_" from the service key.
    $key_trimmed = str_replace('_', '', $key);
    $plugin_definition['services'][$key_trimmed] = $service;
  }
  return $plugin_definition;
}