3 namespace CoreFramework\Factory\Registry;
6 * A factory class for socket registries
8 * @author Roland Haeder <webmaster@shipsimu.org>
10 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
11 * @license GNU GPL 3.0 or any newer version
12 * @link http://www.shipsimu.org
14 * This program is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation, either version 3 of the License, or
17 * (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program. If not, see <http://www.gnu.org/licenses/>.
27 class SocketRegistryFactory extends ObjectFactory {
29 * Protected constructor
33 protected function __construct () {
34 // Call parent constructor
35 parent::__construct(__CLASS__);
39 * Returns a singleton socket registry instance. If an instance is found in
40 * the registry it will be returned, else a new instance is created and
41 * stored in the same registry entry.
43 * @return $registryInstance A socket registry instance
45 public static final function createSocketRegistryInstance () {
46 // Get registry instance
47 $registryInstance = Registry::getRegistry();
49 // Do we have an instance in the registry?
50 if ($registryInstance->instanceExists('socket_registry')) {
51 // Then use this instance
52 $registryInstance = $registryInstance->getInstance('socket_registry');
54 // Get the registry instance
55 $registryInstance = ObjectFactory::createObjectByConfiguredName('socket_registry_class');
57 // Set the instance in registry for further use
58 $registryInstance->addInstance('socket_registry', $registryInstance);
61 // Return the instance
62 return $registryInstance;