You are here

function mathjax_update_8201 in MathJax: LaTeX for Drupal 8.2

Same name and namespace in other branches
  1. 3.0.x mathjax.install \mathjax_update_8201()

Update the CDN URL.

File

./mathjax.install, line 44
MathJax module install.

Code

function mathjax_update_8201() {
  $config_factory = \Drupal::configFactory();
  $config = $config_factory
    ->getEditable('mathjax.settings');
  $url = $config
    ->get('cdn_url');
  $new = 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js';
  $old = 'https://cdn.mathjax.org/mathjax/latest/MathJax.js';
  if (strpos($url, $old) !== FALSE) {
    $url = str_replace($old, $new, $url);
    $config
      ->set('cdn_url', $url)
      ->save(TRUE);
  }
}