Added missing modules, including some as submodules.
[yaffs-website] / web / modules / contrib / linkchecker / linkchecker.drush.inc
1 <?php
2
3 /**
4  * @file
5  * Drush interface to linkchecker functionalities.
6  */
7
8 /**
9  * Implements hook_drush_command().
10  */
11 function linkchecker_drush_command() {
12   $commands = [];
13
14   $commands['linkchecker-analyze'] = [
15     'description' => 'Reanalyzes content for links. Recommended after module has been upgraded.',
16   ];
17   $commands['linkchecker-clear'] = [
18     'description' => 'Clears all link data and analyze content for links. WARNING: Custom link check settings are deleted.',
19   ];
20   $commands['linkchecker-check'] = [
21     'description' => 'Check link status.',
22     // 'options' => array(
23     //   'links' => 'Number of links to check in one round. Default: 1000',
24     // ),
25   ];
26
27   return $commands;
28 }
29
30 /**
31  * Callback for command linkchecker-analyze.
32  */
33 function drush_linkchecker_analyze() {
34   // @fixme
35   global $base_url;
36   if ($base_url == 'http://default') {
37     drush_die('You MUST configure the site $base_url or provide --uri parameter.');
38   }
39
40   // @fixme
41   module_load_include('admin.inc', 'linkchecker');
42
43   // Fake $form_state to leverage _submit function.
44   $form_state = [
45     'values' => ['op' => t('Analyze content for links')],
46     'buttons' => [],
47   ];
48
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();
53   }
54   else {
55     drush_log('No content configured for link analysis.', 'status');
56   }
57 }
58
59 /**
60  * Callback for command linkchecker-analyze.
61  */
62 function drush_linkchecker_clear() {
63   // @fixme
64   global $base_url;
65   if ($base_url == 'http://default') {
66     drush_die('You MUST configure the site $base_url or provide --uri parameter.');
67   }
68
69   // @fixme
70   module_load_include('admin.inc', 'linkchecker');
71
72   // Fake $form_state to leverage _submit function.
73   $form_state = [
74     'values' => ['op' => t('Clear link data and analyze content for links')],
75     'buttons' => [],
76   ];
77
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();
82   }
83   else {
84     drush_log('No content configured for link analysis.', 'status');
85   }
86 }
87
88 /**
89  * Callback for command linkchecker-check.
90  */
91 function drush_linkchecker_check() {
92   drush_log('Starting link checking...', 'info');
93   $run = _linkchecker_check_links();
94   if (!$run) {
95     drush_log('Attempted to re-run link checks while they are already running.', 'warning');
96   }
97   else {
98     drush_log('Finished checking links.', 'completed');
99   }
100 }