You are here

function gatsby_post_update_set_preview_callback_url in Gatsby Live Preview & Incremental Builds 8

Same name and namespace in other branches
  1. 2.0.x gatsby.post_update.php \gatsby_post_update_set_preview_callback_url()

Populates preview_callback_url.

File

./gatsby.post_update.php, line 34
Contains post update hooks.

Code

function gatsby_post_update_set_preview_callback_url() {
  $gatsby_settings = \Drupal::service('config.factory')
    ->getEditable('gatsby.settings');
  $server_urls = array_map('trim', explode(',', \Drupal::config('gatsby.settings')
    ->get('server_url')));
  $server_url = reset($server_urls);
  $gatsby_settings
    ->set('preview_callback_url', sprintf('%s/__refresh', rtrim($server_url, '/')));
  $gatsby_settings
    ->save();
}