You are here

function upgrade in PrintFriendly & PDF 8.2

1 call to upgrade()
printfriendly_page_attachments in ./printfriendly.module
Attach PrintFriendly Script.

File

./printfriendly.module, line 28
Adds PrintFriendly button to chosen node types and provides a block.

Code

function upgrade() {
  $config = \Drupal::configFactory()
    ->getEditable('printfriendly.settings');
  $db_version = $config
    ->get('db_version');
  if ($db_version == NULL) {
    $db_version = 0;
  }
  if ($db_version < 1) {
    switch ($config
      ->get('printfriendly_image')) {
      case 'button-print-blu20.png':
      case 'button-print-whgn20.png':
        $config
          ->set('printfriendly_image', 'print-button-nobg.png');
        break;
      case 'button-print-grnw20.png':
        $config
          ->set('printfriendly_image', 'print-button.png');
        break;
      case 'button-print-gry20.png':
        $config
          ->set('printfriendly_image', 'print-button-gray.png');
        break;
      case 'button-print-blu20.png':
        $config
          ->set('printfriendly_image', 'print-button-nobg.png');
        break;
      case 'pf-button-big.gif':
        $config
          ->set('printfriendly_image', 'printfriendly-button-lg.png');
        break;
      case 'pf-button-big.gif':
        $config
          ->set('printfriendly_image', 'printfriendly-button-lg.png');
        break;
      case 'pf-button-both.gif':
        $config
          ->set('printfriendly_image', 'printfriendly-pdf-button.png');
        break;
      case 'pf-button.gif':
        $config
          ->set('printfriendly_image', 'printfriendly-button.png');
        break;
      case 'pf-icon-small.gif':
        $config
          ->set('printfriendly_image', 'printfriendly-icon-sm.png');
        break;
      case 'pf-icon.gif':
        $config
          ->set('printfriendly_image', 'printfriendly-icon-md.png');
        break;
      case 'pf-pdf-icon.gif':
        $config
          ->set('printfriendly_image', 'pdf-icon-md.png');
        break;
      case 'pf_button_sq_grn_m.png':
      case 'pf_button_sq_gry_m.png':
        $config
          ->set('printfriendly_image', 'printfriendly-icon-lg.png');
        break;
      default:
        $config
          ->set('printfriendly_image', 'printfriendly-button.png');
    }
  }
  $config
    ->set('db_version', 1);
  $config
    ->save();
}