Guest User

Untitled

a guest
Nov 23rd, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. <?php
  2. class CachedSandBoxParser
  3. {
  4. protected
  5. $sandboxparser = null;
  6.  
  7. protected
  8. $cache = array();
  9.  
  10. public function __construct(SandBoxParser $sandboxparser){
  11. $this->sandboxparser = $sandboxparser;
  12. }
  13.  
  14. public function convertWikiText($wikiText, $wgTitle = ''){
  15. $key = sha1($wikiText . $wgTitle);
  16. if( ! array_key_exists($key, $this->cache)){
  17. $content = $this->sandboxparser->convertWikiText($wikiText, $wgTitle);
  18. $this->cache[$key] = $content;
  19. }
  20. return $this->cache[$key];
  21. }
  22. }
Add Comment
Please, Sign In to add comment