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