You are here

function entity_share_cron_update_8101 in Entity Share Cron 8

Same name and namespace in other branches
  1. 8.2 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 22
Install, update and uninstall functions for the Entity share cron module.

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 ($channels as $channel_id => $channel_config) {
      $remotes[$remote_id]['channels'][$channel_id]['operations'] = [
        'create' => TRUE,
        'update' => TRUE,
      ];
    }
  }
  $config
    ->set('remotes', $remotes)
    ->save();
}