MediaWiki REL1_39
SimpleParsoidOutputStash.php
Go to the documentation of this file.
1<?php
2
3namespace MediaWiki\Edit;
4
5use BagOStuff;
6use FormatJson;
7use MediaWiki\Parser\Parsoid\PageBundleJsonTrait;
9use Wikimedia\Parsoid\Core\PageBundle;
10
16 use PageBundleJsonTrait;
17
19 private $bagOfStuff;
20
22 private $duration;
23
28 public function __construct( BagOStuff $bagOfStuff, int $duration ) {
29 $this->bagOfStuff = $bagOfStuff;
30 $this->duration = $duration;
31 }
32
42 public function set( ParsoidRenderId $renderId, PageBundle $bundle ): bool {
43 $pageBundleJson = FormatJson::encode( $this->jsonSerializePageBundle( $bundle ) );
44
45 return $this->bagOfStuff->set( $renderId->getKey(), $pageBundleJson, $this->duration );
46 }
47
57 public function get( ParsoidRenderId $renderId ): ?PageBundle {
58 $pageBundleArray = FormatJson::decode(
59 $this->bagOfStuff->get( $renderId->getKey() ),
60 true
61 ) ?? [];
62 $pageBundle = $this->newPageBundleFromJson( $pageBundleArray );
63
64 return $pageBundle ?: null;
65 }
66
67}
Class representing a cache/ephemeral data store.
Definition BagOStuff.php:85
JSON formatter wrapper class.
__construct(BagOStuff $bagOfStuff, int $duration)
Represents the identity of a specific rendering of a specific revision at some point in time.
Interface for saving and retrieval of Parsoid HTML and Parsoid metadata from storage.
return true
Definition router.php:92