You are here

function commerce_square_update_8002 in Commerce Square Connect 8

Use site state for production access token and expiration time.

1 call to commerce_square_update_8002()
SquareConfigurationUpradeTest::testUpgrade2 in tests/src/Kernel/SquareConfigurationUpradeTest.php
Tests the upgrade to move access token to state.

File

./commerce_square.install, line 119
Contains install and update functions for Commerce Square.

Code

function commerce_square_update_8002() {
  $config_factory = \Drupal::configFactory();
  $state = \Drupal::state();
  $config = $config_factory
    ->getEditable('commerce_square.settings');
  $state
    ->set('commerce_square.production_access_token', $config
    ->get('production_access_token'));
  $state
    ->set('commerce_square.production_access_token_expiry', $config
    ->get('production_access_token_expiry'));
  $config
    ->clear('production_access_token');
  $config
    ->clear('production_access_token_expiry');
  $config
    ->save();
}