]> git.immae.eu Git - github/wallabag/wallabag.git/blame - inc/3rdparty/htmlpurifier/HTMLPurifier/EntityLookup.php
remove autoload section in composer.json
[github/wallabag/wallabag.git] / inc / 3rdparty / htmlpurifier / HTMLPurifier / EntityLookup.php
CommitLineData
d4949327
NL
1<?php\r
2\r
3/**\r
4 * Object that provides entity lookup table from entity name to character\r
5 */\r
6class HTMLPurifier_EntityLookup\r
7{\r
8 /**\r
9 * Assoc array of entity name to character represented.\r
10 * @type array\r
11 */\r
12 public $table;\r
13\r
14 /**\r
15 * Sets up the entity lookup table from the serialized file contents.\r
16 * @param bool $file\r
17 * @note The serialized contents are versioned, but were generated\r
18 * using the maintenance script generate_entity_file.php\r
19 * @warning This is not in constructor to help enforce the Singleton\r
20 */\r
21 public function setup($file = false)\r
22 {\r
23 if (!$file) {\r
24 $file = HTMLPURIFIER_PREFIX . '/HTMLPurifier/EntityLookup/entities.ser';\r
25 }\r
26 $this->table = unserialize(file_get_contents($file));\r
27 }\r
28\r
29 /**\r
30 * Retrieves sole instance of the object.\r
31 * @param bool|HTMLPurifier_EntityLookup $prototype Optional prototype of custom lookup table to overload with.\r
32 * @return HTMLPurifier_EntityLookup\r
33 */\r
34 public static function instance($prototype = false)\r
35 {\r
36 // no references, since PHP doesn't copy unless modified\r
37 static $instance = null;\r
38 if ($prototype) {\r
39 $instance = $prototype;\r
40 } elseif (!$instance) {\r
41 $instance = new HTMLPurifier_EntityLookup();\r
42 $instance->setup();\r
43 }\r
44 return $instance;\r
45 }\r
46}\r
47\r
48// vim: et sw=4 sts=4\r