You are here

function backup_migrate_help in Backup and Migrate 5.0.x

Same name and namespace in other branches
  1. 8.4 backup_migrate.module \backup_migrate_help()
  2. 8.2 backup_migrate.module \backup_migrate_help()
  3. 8.3 backup_migrate.module \backup_migrate_help()
  4. 5.2 backup_migrate.module \backup_migrate_help()
  5. 6.3 backup_migrate.module \backup_migrate_help()
  6. 6.2 backup_migrate.module \backup_migrate_help()
  7. 7.3 backup_migrate.module \backup_migrate_help()
  8. 7.2 backup_migrate.module \backup_migrate_help()

Implements hook_help().

File

./backup_migrate.module, line 211
Primary hook implementations for Backup Migrate.

Code

function backup_migrate_help($route_name, RouteMatchInterface $route_match) {
  if ($route_name == 'help.page.backup_migrate') {
    $help = [];
    $user = User::load(\Drupal::currentUser()
      ->id());

    // Creates url objects for backup_migrate routes.
    $urls = [
      'restore' => 'backup_migrate.restore',
      'schedules' => 'entity.backup_migrate_schedule.collection',
      'manual' => 'backup_migrate.quick_backup',
      'advanced' => 'backup_migrate.advanced_backup',
      'settings' => 'entity.backup_migrate_settings.collection',
      'destination' => 'entity.backup_migrate_destination.collection',
      'sources' => 'entity.backup_migrate_source.collection',
      'backups' => 'backup_migrate.backups',
      'documentation' => 'https://www.drupal.org/docs/8/modules/backup-and-migrate-drupal-8',
      'phpmyadmin' => 'http://www.phpmyadmin.net',
      'cron' => 'http://drupal.org/cron',
    ];
    foreach ($urls as $key => $destination) {
      $urls[$key] = UrlHelper::isValid($destination, TRUE) ? Url::fromUri($destination) : Url::fromRoute($destination);
      $urls[$key]
        ->setOptions([
        'attributes' => [
          'target' => '_blank',
        ],
      ]);
    }
    if ($user
      ->hasPermission('perform backups')) {
      $help['intro'] = [
        '#markup' => t("<p><strong>Backup and Migrate</strong> makes the task of backing up your Drupal database and migrating data from one Drupal install to another easier. It provides a function to backup the entire database to file or download, and to restore from a previous backup. You can also schedule the backup operation. Compression of backup files is also supported. The database backup files created with this module can be imported into this or any other Drupal installation with the @restore, or you can use a database tool such as @phpmyadmin or the mysql command line command. Access for backup migrate is controlled by module permissions, contact the administrator or any privileged user to get access to full module features.</p>", [
          '@restore' => Link::fromTextAndUrl(t('restore feature'), $urls['restore'])
            ->toString(),
          '@phpmyadmin' => Link::fromTextAndUrl(t('phpMyAdmin'), $urls['phpmyadmin'])
            ->toString(),
        ]),
      ];
      $help['manual'] = [
        '#markup' => t("<h3>@title</h3><p>Use this form to run simple @manual of your database. Visit the @documentation for more help using this module.</p>", [
          '@title' => Link::fromTextAndUrl(t('Backup Tab - Quick Backup'), $urls['manual'])
            ->toString(),
          '@manual' => Link::fromTextAndUrl(t('manual backups'), $urls['manual'])
            ->toString(),
          '@documentation' => Link::fromTextAndUrl(t('documentation page'), $urls['documentation'])
            ->toString(),
        ]),
      ];
      $help['advanced'] = [
        '#markup' => t("<h3>@title</h3><p>Use this form to run manual backups of your database with more advanced options. If you have any @profile saved you can load those settings. You can save any of the changes you make to these settings as a new settings profile.</p>", [
          '@title' => Link::fromTextAndUrl(t('Backup Tab - Advanced Backup'), $urls['advanced'])
            ->toString(),
          '@profile' => Link::fromTextAndUrl(t('settings profiles'), $urls['settings'])
            ->toString(),
        ]),
      ];
    }
    if ($user
      ->hasPermission('restore from backup')) {
      $help['restore'] = [
        '#markup' => t("<h3>@title</h3><p>Upload a backup and migrate backup file. The restore function will not work with database dumps from other sources such as @phpmyadmin.</p>", [
          '@title' => Link::fromTextAndUrl(t('Restore Tab'), $urls['restore'])
            ->toString(),
          '@phpmyadmin' => Link::fromTextAndUrl(t('phpMyAdmin'), $urls['phpmyadmin'])
            ->toString(),
        ]),
      ];
    }
    if ($user
      ->hasPermission('administer backup and migrate')) {
      $help['backups'] = [
        '#markup' => t("<h3>@title</h3><p>Backups are the places you can save your backup files to or them load from.</p><p>Files can be saved to a directory on your web server, downloaded to your desktop or emailed to a specified email account. From the @destination tab you can create, delete and edit destinations or list the files which have already been backed up to the available destinations.</p>", [
          '@title' => Link::fromTextAndUrl(t('Saved Backups'), $urls['backups'])
            ->toString(),
          '@destination' => Link::fromTextAndUrl(t('destination'), $urls['destination'])
            ->toString(),
        ]),
      ];
      $help['schedules'] = [
        '#markup' => t("<h3>@title</h3><p>Automatically backup up your database on a regular schedule using @cron.</p><p>Each schedule will run a maximum of once per cron run, so they will not run more frequently than your cron is configured to run. If you specify a number of backups to keep for a schedule, old backups will be deleted as new ones created. <strong>If specify a number of files to keep other backup files in that schedule's @destination will get deleted</strong>.<p>", [
          '@title' => Link::fromTextAndUrl(t('Shedules Tab'), $urls['schedules'])
            ->toString(),
          '@cron' => Link::fromTextAndUrl(t('cron'), $urls['cron'])
            ->toString(),
          '@destination' => Link::fromTextAndUrl(t('destination'), $urls['destination'])
            ->toString(),
        ]),
      ];
      $help['settings'] = [
        '#markup' => t("<h3>@title</h3><p>Settings are profile. Settings store your table exclusion settings as well as your backup file name, compression and timestamp settings. You can use profiles in @schedules and for @manual.</p><p>You can create new profiles using the add profiles tab or by checking the 'Save these settings' button on the advanced backup page.</p>", [
          '@title' => Link::fromTextAndUrl(t('Settings Tab - Settings Profiles'), $urls['settings'])
            ->toString(),
          '@schedules' => Link::fromTextAndUrl(t('schedules'), $urls['schedules'])
            ->toString(),
          '@manual' => Link::fromTextAndUrl(t('quick backups'), $urls['manual'])
            ->toString(),
        ]),
      ];
      $help['destination'] = [
        '#markup' => t("<h3>@title</h3><p>Destinations store your custom created destination settings as backup server folders or external clouds (Clouds destinations are in work, check the module issues lists).</p>", [
          '@title' => Link::fromTextAndUrl(t('Settings Tab - Destinations'), $urls['destination'])
            ->toString(),
        ]),
      ];
      $help['sources'] = [
        '#markup' => t("<h3>@title</h3><p>Sources store your source settings you want to backup, for now is available 4 default sources to use. Follow module issues list for new source features.</p>", [
          '@title' => Link::fromTextAndUrl(t('Settings Tab - Sources'), $urls['sources'])
            ->toString(),
        ]),
      ];
    }
    $output = '';
    foreach ($help as $key => $value) {
      $output .= render($value);
    }
    return $output;
  }
}