Commit a5447b09 authored by elaman's avatar elaman Committed by DamienMcKenna

Issue #2947276 by liliancatanoi90, rajeshwari10, minakshiPh, Elaman, emartoni,...

Issue #2947276 by liliancatanoi90, rajeshwari10, minakshiPh, Elaman, emartoni, DamienMcKenna, alonaoneill: Missing module help.
parent a36f220c
......@@ -2,6 +2,8 @@ Backup and Migrate 8.x-4.x-dev, xxxx-xx-xx
------------------------------------------
#2975065 by Dinu Rodnitchi, Alex Andrascu: Add encryption support.
#3041404 by DamienMcKenna: Add CHANGELOG.txt.
#2947276 by liliancatanoi90, rajeshwari10, minakshiPh, Elaman, emartoni,
DamienMcKenna, alonaoneill: Missing module help.
Backup and Migrate 8.x-4.0, 2018-03-29
......
......@@ -13,6 +13,11 @@ use Drupal\backup_migrate\Entity\Schedule;
use Drupal\backup_migrate\Entity\Source;
use Drupal\Core\Form\FormStateInterface;
use Symfony\Component\ClassLoader\Psr4ClassLoader;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\user\Entity\User;
use Drupal\Component\Utility\UrlHelper;
use Drupal\Core\Url;
use Drupal\Core\Link;
// Autoload the required classes.
// @todo Apparently this isn't working on Windows machines.
......@@ -203,3 +208,105 @@ function backup_migrate_form_alter(&$form, FormStateInterface $form_state, $form
}
}
}
/**
* Implements hook_help().
*/
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 specifiy 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 destionation 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;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment