You are here

function openid_connect_update_8208 in OpenID Connect / OAuth client 2.x

Update generic plugins with scopes.

File

./openid_connect.install, line 267
Install, update and uninstall functions for the OpenID Connect module.

Code

function openid_connect_update_8208() {
  $clients = \Drupal::entityTypeManager()
    ->getStorage('openid_connect_client')
    ->loadByProperties([
    'plugin' => 'generic',
  ]);
  foreach ($clients as $client) {
    $config = $client
      ->getPlugin()
      ->getConfiguration();
    if (empty($config['scopes'])) {
      $client
        ->getPlugin()
        ->setConfiguration([
        'scopes' => [
          'openid',
          'email',
        ],
      ]);
      $client
        ->save();
    }
  }
}