config = $config; $this->logger = $logger; } /** * Reanalyzes content for links. Recommended after module has been upgraded. * * @command linkchecker:analyze * * @aliases lca */ public function analyze() { // @fixme global $base_url; if ($base_url == 'http://default') { $this->logger()->error('You MUST configure the site $base_url or provide --uri parameter.'); } // @fixme module_load_include('admin.inc', 'linkchecker'); // Fake $form_state to leverage _submit function. $form_state = [ 'values' => ['op' => $this->t('Analyze content for links')], 'buttons' => [], ]; $node_types = linkchecker_scan_node_types(); if (!empty($node_types) || \Drupal::config('linkchecker.settings')->get('scan_blocks')) { linkchecker_analyze_links_submit(NULL, $form_state); drush_backend_batch_process(); } else { $this->logger()->warning('No content configured for link analysis.'); } } /** * Clears all link data and analyze content for links. * * WARNING: Custom link check settings are deleted. * * @command linkchecker:clear * * @aliases lccl */ public function clear() { // @fixme global $base_url; if ($base_url == 'http://default') { $this->logger()->error('You MUST configure the site $base_url or provide --uri parameter.'); return; } // @fixme module_load_include('admin.inc', 'linkchecker'); // Fake $form_state to leverage _submit function. $form_state = [ 'values' => ['op' => $this->t('Clear link data and analyze content for links')], 'buttons' => [], ]; $node_types = linkchecker_scan_node_types(); if (!empty($node_types) || \Drupal::config('linkchecker.settings') ->get('scan_blocks')) { linkchecker_clear_analyze_links_submit(NULL, $form_state); drush_backend_batch_process(); } else { $this->logger()->warning('No content configured for link analysis.'); } } /** * Check link status. * * @command linkchecker:check * * @aliases lcch */ public function check() { $this->logger()->info('Starting link checking...'); $run = _linkchecker_check_links(); if (!$run) { $this->logger()->warning('Attempted to re-run link checks while they are already running.'); } else { $this->logger()->info('Finished checking links.'); } } }