5 * Drush interface to linkchecker functionalities.
9 * Implements hook_drush_command().
11 function linkchecker_drush_command() {
14 $commands['linkchecker-analyze'] = [
15 'description' => 'Reanalyzes content for links. Recommended after module has been upgraded.',
17 $commands['linkchecker-clear'] = [
18 'description' => 'Clears all link data and analyze content for links. WARNING: Custom link check settings are deleted.',
20 $commands['linkchecker-check'] = [
21 'description' => 'Check link status.',
22 // 'options' => array(
23 // 'links' => 'Number of links to check in one round. Default: 1000',
31 * Callback for command linkchecker-analyze.
33 function drush_linkchecker_analyze() {
36 if ($base_url == 'http://default') {
37 drush_die('You MUST configure the site $base_url or provide --uri parameter.');
41 module_load_include('admin.inc', 'linkchecker');
43 // Fake $form_state to leverage _submit function.
45 'values' => ['op' => t('Analyze content for links')],
49 $node_types = linkchecker_scan_node_types();
50 if (!empty($node_types) || \Drupal::config('linkchecker.settings')->get('scan_blocks')) {
51 linkchecker_analyze_links_submit(NULL, $form_state);
52 drush_backend_batch_process();
55 drush_log('No content configured for link analysis.', 'status');
60 * Callback for command linkchecker-analyze.
62 function drush_linkchecker_clear() {
65 if ($base_url == 'http://default') {
66 drush_die('You MUST configure the site $base_url or provide --uri parameter.');
70 module_load_include('admin.inc', 'linkchecker');
72 // Fake $form_state to leverage _submit function.
74 'values' => ['op' => t('Clear link data and analyze content for links')],
78 $node_types = linkchecker_scan_node_types();
79 if (!empty($node_types) || \Drupal::config('linkchecker.settings')->get('scan_blocks')) {
80 linkchecker_clear_analyze_links_submit(NULL, $form_state);
81 drush_backend_batch_process();
84 drush_log('No content configured for link analysis.', 'status');
89 * Callback for command linkchecker-check.
91 function drush_linkchecker_check() {
92 drush_log('Starting link checking...', 'info');
93 $run = _linkchecker_check_links();
95 drush_log('Attempted to re-run link checks while they are already running.', 'warning');
98 drush_log('Finished checking links.', 'completed');