From: Roland Häder Date: Sat, 30 Apr 2011 00:11:14 +0000 (+0000) Subject: Rewrote unit source factory to registry pattern X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=9fb2f0560e09b3b391bb60190169b398ca40ddfd;p=hub.git Rewrote unit source factory to registry pattern --- diff --git a/application/hub/main/factories/source/units/class_UnitSourceFactory.php b/application/hub/main/factories/source/units/class_UnitSourceFactory.php index 6c9ded734..1afe986ae 100644 --- a/application/hub/main/factories/source/units/class_UnitSourceFactory.php +++ b/application/hub/main/factories/source/units/class_UnitSourceFactory.php @@ -22,11 +22,6 @@ * along with this program. If not, see . */ class UnitSourceFactory extends ObjectFactory { - /** - * Source instances - */ - private static $sourceInstances = array(); - /** * Protected constructor * @@ -45,16 +40,22 @@ class UnitSourceFactory extends ObjectFactory { */ public static final function createUnitSourceInstance ($unitType) { // Do we have cache? - if (!isset(self::$sourceInstances[$unitType])) { + if (!Registry::getRegistry()->instanceExists($unitType . '_unit_source')) { // Then construct the class' configuraton entry $className = '' . $unitType . '_unit_source_class'; // Get a class from that configuration entry - self::$sourceInstances[$unitType] = self::createObjectByConfiguredName($className); - } // END - if + $sourceInstance = self::createObjectByConfiguredName($className); + + // Add it to the registry + Registry::getRegistry()->addInstance($unitType . '_unit_source', $sourceInstance); + } else { + // Get it from registry + $sourceInstance = Registry::getRegistry()->getInstance($unitType . '_unit_source'); + } // For any purposes, return the source instance - return self::$sourceInstances[$unitType]; + return $sourceInstance; } }