You are here

function entity_share_cron_update_8101 in Entity Share Cron 8.2

Same name and namespace in other branches
  1. 8 entity_share_cron.install \entity_share_cron_update_8101()
  2. 3.0.x entity_share_cron.install \entity_share_cron_update_8101()

Set enabled operations for channels.

File

./entity_share_cron.install, line 24

Code

function entity_share_cron_update_8101() {
  $config = \Drupal::configFactory()
    ->getEditable('entity_share_cron.settings');

  // Enables both operations (create and update) for each channel.
  $remotes = $config
    ->get('remotes');
  foreach ($remotes as $remote_id => $remote_config) {
    $channels = isset($remote_config['channels']) ? $remote_config['channels'] : [];
    foreach (array_keys($channels) as $channel_id) {
      $remotes[$remote_id]['channels'][$channel_id]['operations'] = [
        'create' => TRUE,
        'update' => TRUE,
      ];
    }
  }
  $config
    ->set('remotes', $remotes)
    ->save();
}