You are here

function fillpdf_update_8110 in FillPDF 5.0.x

Same name and namespace in other branches
  1. 8.4 fillpdf.install \fillpdf_update_8110()

Install 'fillpdf_legacy' sub-module, uninstall 'fillpdf_next' sub-module.

File

./fillpdf.install, line 202
Install functions for FillPDF.

Code

function fillpdf_update_8110() {

  /** @var \Drupal\Core\Extension\ModuleInstaller $module_installer */
  $module_installer = \Drupal::service('module_installer');
  if (\Drupal::moduleHandler()
    ->moduleExists('fillpdf_next')) {
    $module_installer
      ->uninstall([
      'fillpdf_next',
    ]);
  }
  if (!\Drupal::moduleHandler()
    ->moduleExists('fillpdf_legacy')) {
    $module_installer
      ->install([
      'fillpdf_legacy',
    ]);
    $base_url = \Drupal::request()
      ->getBasePath();
    return new FormattableMarkup("Installed the <a href=':list'>FillPDF legacy backend support</a> sub-module.<br />If you're not using any legacy backends, you may safely <a href=':uninstall'>uninstall it again.</a>.", [
      ':list' => Url::fromRoute('system.modules_list', [], [
        'fragment' => 'module-fillpdf',
      ])
        ->setOption('base_url', $base_url)
        ->toString(),
      ':uninstall' => Url::fromRoute('system.modules_uninstall')
        ->setOption('base_url', $base_url)
        ->toString(),
    ]);
  }
}