You are here

protected function MinifyHTMLExit::minifyhtmlCallback in Minify Source HTML 8

Helper function to individually call our <tag> processors.

Parameters

string $pattern: The pattern for the search.

string $callback: The callback function to use.

Return value

string The content with placeholders.

1 call to MinifyHTMLExit::minifyhtmlCallback()
MinifyHTMLExit::minify in src/EventSubscriber/MinifyHTMLExit.php
Helper function to minify HTML.

File

src/EventSubscriber/MinifyHTMLExit.php, line 184

Class

MinifyHTMLExit
Minifies the HTML of the response.

Namespace

Drupal\minifyhtml\EventSubscriber

Code

protected function minifyhtmlCallback($pattern, $callback) {
  $content = preg_replace_callback($pattern, [
    $this,
    $callback,
  ], $this->content);
  if ($error = preg_last_error()) {
    $this->logger
      ->get('minifyhtml')
      ->error('Preg error. The error code is @error. You can view what this error code is by viewing http://php.net/manual/en/function.preg-last-error.php', [
      '@error' => $error,
    ]);
  }
  return $content;
}