You are here

public function ParsedMarkdown::unserialize in Markdown 8.2

File

src/Render/ParsedMarkdown.php, line 227

Class

ParsedMarkdown
The end result of parsing markdown into HTML.

Namespace

Drupal\markdown\Render

Code

public function unserialize($serialized) {
  $data = unserialize($serialized);

  // Data was gzipped.
  if ($data['gzip']) {

    // Decompress data if PHP has gzip capabilities.
    if (extension_loaded('zlib')) {

      /* @noinspection PhpComposerExtensionStubsInspection */
      $data['object'] = gzdecode(base64_decode($data['object']));
    }
    else {
      $this->markdown = sprintf('This cached %s object was stored using gzip compression. Unable to decompress. The PHP on this server must have the "zlib" extension installed.', static::class);
      $this->html = $this->markdown;
      return;
    }
  }
  $object = unserialize($data['object']);
  foreach ($object as $prop => $value) {
    $this->{$prop} = $value;
  }
}