You are here

protected function PrintableFormatBase::extractLinks in Printer and PDF versions for Drupal 8+ 8

Same name and namespace in other branches
  1. 2.x src/Plugin/PrintableFormatBase.php \Drupal\printable\Plugin\PrintableFormatBase::extractLinks()

Extracts the links present in HTML string.

Parameters

string $content: The HTML of the page to be added.

Return value

string The HTML string with presence of links dependending on configuration.

2 calls to PrintableFormatBase::extractLinks()
PdfFormat::buildPdfContent in modules/printable_pdf/src/Plugin/PrintableFormat/PdfFormat.php
Get the HTML content for PDF generation.
PrintableFormatBase::getOutput in src/Plugin/PrintableFormatBase.php
Get the HTML output of the whole page and pass to the response object.

File

src/Plugin/PrintableFormatBase.php, line 196

Class

PrintableFormatBase
Provides a base class for Filter plugins.

Namespace

Drupal\printable\Plugin

Code

protected function extractLinks($content) {
  if ($this->configFactory
    ->get('printable.settings')
    ->get('extract_links')) {
    $rendered_page = $this->linkExtractor
      ->extract($content);
  }
  else {
    $rendered_page = $this->linkExtractor
      ->removeAttribute($content, 'href');
  }
  return $rendered_page;
}