3 * A factory class for XML template engines. All instances generated by this
4 * factory does have language support disabled and XML-compacting enabled (to
5 * save memory/network load).
7 * @author Roland Haeder <webmaster@ship-simu.org>
9 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2011 Hub Developer Team
10 * @license GNU GPL 3.0 or any newer version
11 * @link http://www.ship-simu.org
13 * This program is free software: you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation, either version 3 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program. If not, see <http://www.gnu.org/licenses/>.
26 class XmlTemplateEngineFactory extends ObjectFactory {
28 * Protected constructor
32 protected function __construct () {
33 // Call parent constructor
34 parent::__construct(__CLASS__);
38 * Returns a singleton network package instance. If an instance is found in
39 * the registry it will be returned, else a new instance is created and
40 * stored in the same registry entry.
42 * @param $configEntry Config entry name for the template engine
43 * @return $templateInstance A template engine instance
45 public static final function createXmlTemplateEngineInstance ($configEntry) {
46 // Do we have an instance in the registry?
47 if (Registry::getRegistry()->instanceExists($configEntry)) {
48 // Then use this instance
49 $templateInstance = Registry::getRegistry()->getInstance($configEntry);
51 // Now prepare the tags instance
52 $templateInstance = ObjectFactory::createObjectByConfiguredName($configEntry);
54 // Disable language support
55 $templateInstance->enableLanguageSupport(false);
58 * Enable compacting/rewriting of the XML to save bandwidth from XML
59 * comments. This is expensive and should be avoided in general.
61 $templateInstance->enableXmlCompacting();
63 // Set the instance in registry for further use
64 Registry::getRegistry()->addInstance($configEntry, $templateInstance);
67 // Return the instance
68 return $templateInstance;