]> git.mxchange.org Git - hub.git/commitdiff
Now the factory method is moved over to the newly introduced PackageFactory class
authorRoland Häder <roland@mxchange.org>
Sat, 27 Mar 2010 03:33:08 +0000 (03:33 +0000)
committerRoland Häder <roland@mxchange.org>
Sat, 27 Mar 2010 03:33:08 +0000 (03:33 +0000)
.gitattributes
application/hub/main/factories/package/.htaccess [new file with mode: 0644]
application/hub/main/factories/package/class_PackageFactory.php [new file with mode: 0644]
application/hub/main/helper/hub/announcement/class_HubDescriptorHelper.php
application/hub/main/nodes/class_BaseHubNode.php

index 0f747dee390d19f2e00facb6bb21f3eb4eccd16d..84a41d66e22a15f97a95df72e4361dfa85863d14 100644 (file)
@@ -107,6 +107,7 @@ application/hub/main/database/wrapper/class_NodeListDatabaseWrapper.php -text
 application/hub/main/decorators/.htaccess -text
 application/hub/main/decorators/class_BaseDecorator.php -text
 application/hub/main/factories/.htaccess -text
+application/hub/main/factories/package/.htaccess -text
 application/hub/main/factories/states/.htaccess -text
 application/hub/main/factories/states/class_StateFactory.php -text
 application/hub/main/filter/.htaccess -text
diff --git a/application/hub/main/factories/package/.htaccess b/application/hub/main/factories/package/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/factories/package/class_PackageFactory.php b/application/hub/main/factories/package/class_PackageFactory.php
new file mode 100644 (file)
index 0000000..e0b6d7e
--- /dev/null
@@ -0,0 +1,70 @@
+<?php
+/**
+ * A factory class for packages
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009, 2010 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class PackageFactory extends ObjectFactory {
+       /**
+        * Returns a singleton network package instance. If an instance is found in
+        * the registry it will be returned, else a new instance is created and
+        * stored in the same registry entry.
+        *
+        * @return      $packageInstance        A network package instance
+        */
+       public static final function createPackageInstance () {
+               // Do we have an instance in the registry?
+               if (Registry::getRegistry()->instanceExists('network_package')) {
+                       // Then use this instance
+                       $packageInstance = Registry::getRegistry()->getInstance('network_package');
+               } else {
+                       /**
+                        * Prepare the compressor for our package, GZIP should be fine but we
+                        * keep it open here so you can experiment with the settings and don't
+                        * need to touch any code.
+                        */
+                       $compressorInstance = ObjectFactory::createObjectByConfiguredName('raw_package_compressor_class');
+
+                       // Prepare the decorator compressor (for later flawless and easy updates)
+                       $compressorInstance = ObjectFactory::createObjectByConfiguredName('deco_package_compressor_class', array($compressorInstance));
+
+                       // Now prepare the network package for delivery so only need to do this
+                       // once just before the "big announcement loop".
+                       $packageInstance = ObjectFactory::createObjectByConfiguredName('network_package_class', array($compressorInstance));
+
+                       // Set the instance in registry for further use
+                       Registry::getRegistry()->addInstance('network_package', $packageInstance);
+               }
+
+               // Return the instance
+               return $packageInstance;
+       }
+
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+}
+?>
index 83b13ad6c88b270887a671d4c8eac059590f6396..7388345d9e83b8a164ac50170e79b47e4cfe552a 100644 (file)
@@ -102,8 +102,8 @@ class HubDescriptorHelper extends BaseHubHelper {
                // Compile the template, this inserts the loaded node data into the gaps.
                $this->getTemplateInstance()->compileTemplate();
 
-               // Get a package instance
-               $packageInstance = $this->getNodeInstance()->createPackageInstance();
+               // Get a singleton package instance
+               $packageInstance = PackageFactory::createPackageInstance();
 
                // Next, feed the content in. The network package class is a pipe-through class.
                $packageInstance->enqueueRawDataFromTemplate($this);
index 5cbe9033932da030ed312af67a24d7526613703f..f9d1cdf9c6425fe44b6d21b902650faf98457242 100644 (file)
@@ -614,42 +614,6 @@ class BaseHubNode extends BaseHubSystem implements Updateable {
                // Return value
                return $isActive;
        }
-
-       /**
-        * Returns a singleton network package instance. If an instance is found in
-        * the registry it will be returned, else a new instance is created and
-        * stored in the same registry entry.
-        *
-        * @param       $compressorInstance             A Compressor instance
-        * @return      $packageInstance        A network package instance
-        */
-       public function createPackageInstance (Compressor $compressorInstance) {
-               // Do we have an instance in the registry?
-               if (Registry::getRegistry()->instanceExists('network_package')) {
-                       // Then use this instance
-                       $packageInstance = Registry::getRegistry()->getInstance('network_package');
-               } else {
-                       /**
-                        * Prepare the compressor for our package, GZIP should be fine but we
-                        * keep it open here so you can experiment with the settings and don't
-                        * need to touch any code.
-                        */
-                       $compressorInstance = ObjectFactory::createObjectByConfiguredName('raw_package_compressor_class');
-
-                       // Prepare the decorator compressor (for later flawless and easy updates)
-                       $compressorInstance = ObjectFactory::createObjectByConfiguredName('deco_package_compressor_class', array($compressorInstance));
-
-                       // Now prepare the network package for delivery so only need to do this
-                       // once just before the "big announcement loop".
-                       $packageInstance = ObjectFactory::createObjectByConfiguredName('network_package_class', array($compressorInstance));
-
-                       // Set the instance in registry for further use
-                       Registry::getRegistry()->addInstance('network_package', $packageInstance);
-               }
-
-               // Return the instance
-               return $packageInstance;
-       }
 }
 
 // [EOF]