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