Add entity files to xc-deps.
[xhtml-compiler.git] / XHTMLCompiler.php
blobf4fdd99816baefcbf123e85e644add355b0d4421
1 <?php
3 /**
4 * Super singleton registry that manages application context.
5 */
6 class XHTMLCompiler
9 // SINGLETON FUNCTIONALITY
11 /** Private instance of singleton */
12 private static $_instance;
14 /** Private constructor, prevents other people from making it */
15 private function __construct() {
16 $this->loadConf();
19 /** Retrieves the single instance of the object */
20 static public function getInstance() {
21 if(is_null(self::$_instance)) {
22 self::$_instance = new self();
24 return self::$_instance;
27 /**
28 * Overloads the instance with another one, usually a mock object
29 * @param Object substitute for XHTMLCompiler
31 static public function setInstance($stub) {
32 self::$_instance = $stub;
35 // REGISTRY FUNCTIONALITY
37 /** Private instance of PHP wrapper */
38 private static $_PHPWrapperInstance;
40 /** Retrieves the single instance of the PHP wrapper */
41 static public function getPHPWrapper() {
42 if(is_null(self::$_PHPWrapperInstance)) {
43 self::$_PHPWrapperInstance = new XHTMLCompiler_PHP();
45 return self::$_PHPWrapperInstance;
48 /**
49 * Overloads the instance with another one, usually a mock object
50 * @param Object substitute for XHTMLCompiler
52 static public function setPHPWrapper($stub) {
53 self::$_PHPWrapperInstance = $stub;
56 // PLUGIN/CONFIGURATION FUNCTIONALITY
58 protected $configKeys = array('allowed_dirs', 'directory_index',
59 'indexed_dirs', 'web_path', 'web_domain', 'viewvc_url',
60 'svn_headurl_munge');
61 protected $config = array();
62 protected $filterManager;
64 public function loadConf() {
65 $filters = new XHTMLCompiler_FilterManager();
66 require 'config.default.php'; // defaults
67 require 'config.php'; // user
68 $this->config = compact($this->configKeys);
69 $this->filterManager = $filters;
71 public function getConf($key) {
72 if (!isset($this->config[$key])) throw new Exception('No such configuration keypair');
73 return $this->config[$key];
75 public function getFilterManager() {return $this->filterManager;}