5 * Installation file for Link Checker module.
8 use Drupal\user\Entity\User;
11 * Implements hook_install().
13 function linkchecker_install() {
14 $linkchecker_default_impersonate_account = User::load(1);
15 \Drupal::configFactory()->getEditable('linkchecker.settings')->set('error.impersonate_account', $linkchecker_default_impersonate_account->getAccountName())->save();
19 * Implements hook_schema().
21 function linkchecker_schema() {
23 $schema['linkchecker_block_custom'] = array(
24 'description' => 'Stores all link references for custom blocks.',
29 'description' => 'Primary Key: Unique {block_custom}.bid.',
34 'description' => 'Primary Key: Unique {linkchecker_link}.lid.',
37 'primary key' => array('bid', 'lid'),
38 'foreign keys' => array(
40 'table' => 'block_custom',
41 'columns' => array('bid' => 'bid'),
44 'table' => 'linkchecker_link',
45 'columns' => array('lid' => 'lid'),
48 'indexes' => array('lid' => array('lid')),
51 $schema['linkchecker_comment'] = array(
52 'description' => 'Stores all link references for comments.',
57 'description' => 'Primary Key: Unique {comment}.cid.',
62 'description' => 'Primary Key: Unique {linkchecker_link}.lid.',
65 'primary key' => array('cid', 'lid'),
66 'foreign keys' => array(
69 'columns' => array('cid' => 'cid'),
72 'table' => 'linkchecker_link',
73 'columns' => array('lid' => 'lid'),
76 'indexes' => array('lid' => array('lid')),
79 $schema['linkchecker_node'] = array(
80 'description' => 'Stores all link references for nodes.',
85 'description' => 'Primary Key: Unique {node}.nid.',
90 'description' => 'Primary Key: Unique {linkchecker_link}.lid.',
93 'primary key' => array('nid', 'lid'),
94 'foreign keys' => array(
97 'columns' => array('nid' => 'nid'),
100 'table' => 'linkchecker_link',
101 'columns' => array('lid' => 'lid'),
104 'indexes' => array('lid' => array('lid')),
107 $schema['linkchecker_link'] = array(
108 'description' => 'Stores all links.',
113 'description' => 'Primary Key: Unique link ID.',
119 'description' => 'The indexable hash of the {linkchecker_link}.url.',
124 'description' => 'The full qualified link.',
131 'description' => 'The method for checking links (HEAD, GET, POST).',
137 'description' => 'HTTP status code from link checking.',
142 'description' => 'The error message received from the remote server while doing link checking.',
144 'fail_count' => array(
148 'description' => 'Fail count of unsuccessful link checks. No flapping detection. (Successful = 0, Unsuccessful = fail_count+1).',
150 'last_checked' => array(
154 'description' => 'Timestamp of the last link check.',
160 'description' => 'Boolean indicating if a link should be checked or not.',
163 'primary key' => array('lid'),
164 'unique keys' => array('urlhash' => array('urlhash')),
166 'method' => array('method'),
167 'code' => array('code'),
168 'fail_count' => array('fail_count'),
169 'last_checked' => array('last_checked'),
170 'status' => array('status'),
178 * Implements hook_modules_uninstalled().
180 * If the core modules are disabled the integration need to be disabled.
182 function linkchecker_modules_uninstalled($modules) {
183 // Disable link checks for custom blocks.
184 if (in_array('block', $modules)) {
185 \Drupal::config('linkchecker.settings')->set('scan_blocks', 0);
186 drupal_set_message(t('Link checks for blocks have been disabled.'));
189 // Disable link checks for comments.
190 if (in_array('comment', $modules)) {
191 foreach (node_type_get_names() as $type => $name) {
192 // @fixme: This is incorrect. The variable is inside node.type.*.third_party.linkchecker
193 //\Drupal::config('node.type.' . $type . '.third_party.linkchecker')->clear('scan_comment');
194 //\Drupal::service('config.manager');
195 //$type->unsetThirdPartySetting('linkchecker', 'scan_comment', $form_state->getValue('scan_comment'));
197 drupal_set_message(t('Link checks for comments have been disabled.'));