You are here

public function InlineLinkExtractor::removeAttribute in Printer and PDF versions for Drupal 8+ 2.x

Same name and namespace in other branches
  1. 8 src/LinkExtractor/InlineLinkExtractor.php \Drupal\printable\LinkExtractor\InlineLinkExtractor::removeAttribute()

Remove href from links in the given HTML string.

Parameters

string $content: The HTML string to remove links from.

string $attr: The attribute which has to be removed from the link.

Return value

string The HTML string, with links removed.

Overrides LinkExtractorInterface::removeAttribute

File

src/LinkExtractor/InlineLinkExtractor.php, line 65

Class

InlineLinkExtractor
Link extractor.

Namespace

Drupal\printable\LinkExtractor

Code

public function removeAttribute($content, $attr) {
  $this->crawler
    ->addContent($content);
  $this->crawler
    ->filter('a')
    ->each(function (HtmlPageCrawler $anchor, $uri) {
    $anchor
      ->removeAttribute('href');
  });
  return (string) $this->crawler;
}