From: Roland Häder Date: Sat, 25 Feb 2023 09:34:42 +0000 (+0100) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=73c0372c1dfd123b7b646ef359af1cd98c130ae7;p=core.git Continued: - getRegistry() now have a mandatory parameter --- diff --git a/framework/main/classes/class_BaseFrameworkSystem.php b/framework/main/classes/class_BaseFrameworkSystem.php index 79380a23..431c3a10 100644 --- a/framework/main/classes/class_BaseFrameworkSystem.php +++ b/framework/main/classes/class_BaseFrameworkSystem.php @@ -417,7 +417,7 @@ abstract class BaseFrameworkSystem extends stdClass implements FrameworkInterfac * @return void */ public final function setWebOutputInstance (OutputStreamer $webInstance) { - ObjectRegistry::getRegistry()->addInstance('web_output', $webInstance); + ObjectRegistry::getRegistry('generic')->addInstance('web_output', $webInstance); } /** @@ -426,7 +426,7 @@ abstract class BaseFrameworkSystem extends stdClass implements FrameworkInterfac * @return $webOutputInstance - Instance to class WebOutput */ public final function getWebOutputInstance () { - return ObjectRegistry::getRegistry()->getInstance('web_output'); + return ObjectRegistry::getRegistry('generic')->getInstance('web_output'); } /** diff --git a/framework/main/classes/commands/html/class_HtmlConfirmCommand.php b/framework/main/classes/commands/html/class_HtmlConfirmCommand.php index 93eee3bb..79f8bdf4 100644 --- a/framework/main/classes/commands/html/class_HtmlConfirmCommand.php +++ b/framework/main/classes/commands/html/class_HtmlConfirmCommand.php @@ -114,7 +114,7 @@ class HtmlConfirmCommand extends BaseCommand implements Commandable { // Get user instance try { - $userInstance = ObjectRegistry::getRegistry()->getInstance('user'); + $userInstance = ObjectRegistry::getRegistry('generic')->getInstance('user'); } catch (NullPointerException $e) { // Not found user, e.g. when the user is somehow invalid $responseInstance->redirectToConfiguredUrl('html_cmd_user_is_null'); diff --git a/framework/main/classes/commands/html/class_HtmlLoginAreaCommand.php b/framework/main/classes/commands/html/class_HtmlLoginAreaCommand.php index 0b122fe2..0c59b7ef 100644 --- a/framework/main/classes/commands/html/class_HtmlLoginAreaCommand.php +++ b/framework/main/classes/commands/html/class_HtmlLoginAreaCommand.php @@ -92,7 +92,7 @@ class HtmlLoginAreaCommand extends BaseCommand implements Commandable { */ public function execute (Requestable $requestInstance, Responseable $responseInstance) { // Get the action instance from registry - $actionInstance = ObjectRegistry::getRegistry()->getInstance('action'); + $actionInstance = ObjectRegistry::getRegistry('generic')->getInstance('action'); // Do we have an action here? if ($actionInstance instanceof PerformableAction) { @@ -200,7 +200,7 @@ class HtmlLoginAreaCommand extends BaseCommand implements Commandable { $actionInstance->addExtraFilters($controllerInstance, $requestInstance); // Remember this action in registry - ObjectRegistry::getRegistry()->addInstance('action', $actionInstance); + ObjectRegistry::getRegistry('generic')->addInstance('action', $actionInstance); } } diff --git a/framework/main/classes/commands/html/class_HtmlLoginCommand.php b/framework/main/classes/commands/html/class_HtmlLoginCommand.php index 2c652736..bea535be 100644 --- a/framework/main/classes/commands/html/class_HtmlLoginCommand.php +++ b/framework/main/classes/commands/html/class_HtmlLoginCommand.php @@ -73,7 +73,7 @@ class HtmlLoginCommand extends BaseCommand implements Commandable { */ public function execute (Requestable $requestInstance, Responseable $responseInstance) { // Set request instance as extra instance - ObjectRegistry::getRegistry()->addInstance('extra', $this); + ObjectRegistry::getRegistry('generic')->addInstance('extra', $this); // Get the application instance $applicationInstance = ApplicationHelper::getSelfInstance(); diff --git a/framework/main/classes/commands/html/class_HtmlRegisterCommand.php b/framework/main/classes/commands/html/class_HtmlRegisterCommand.php index a805930c..56b26085 100644 --- a/framework/main/classes/commands/html/class_HtmlRegisterCommand.php +++ b/framework/main/classes/commands/html/class_HtmlRegisterCommand.php @@ -73,7 +73,7 @@ class HtmlRegisterCommand extends BaseCommand implements Commandable { */ public function execute (Requestable $requestInstance, Responseable $responseInstance) { // Set request instance as extra instance - ObjectRegistry::getRegistry()->addInstance('extra', $this); + ObjectRegistry::getRegistry('generic')->addInstance('extra', $this); // Get the application instance $applicationInstance = ApplicationHelper::getSelfInstance(); diff --git a/framework/main/classes/commands/html/class_HtmlResendLinkCommand.php b/framework/main/classes/commands/html/class_HtmlResendLinkCommand.php index dd0b683e..ebb2c5d3 100644 --- a/framework/main/classes/commands/html/class_HtmlResendLinkCommand.php +++ b/framework/main/classes/commands/html/class_HtmlResendLinkCommand.php @@ -74,7 +74,7 @@ class HtmlResendLinkCommand extends BaseCommand implements Commandable { */ public function execute (Requestable $requestInstance, Responseable $responseInstance) { // Get user instance from registry - $userInstance = ObjectRegistry::getRegistry()->getInstance('user'); + $userInstance = ObjectRegistry::getRegistry('generic')->getInstance('user'); // Get an application instance $applicationInstance = ApplicationHelper::getSelfInstance(); diff --git a/framework/main/classes/controller/class_BaseController.php b/framework/main/classes/controller/class_BaseController.php index 8067fcba..2535df01 100644 --- a/framework/main/classes/controller/class_BaseController.php +++ b/framework/main/classes/controller/class_BaseController.php @@ -68,7 +68,7 @@ abstract class BaseController extends BaseFrameworkSystem implements Registerabl $this->initFilterChain(self::FILTER_CHAIN_POST_COMMAND); // Add this controller to the registry - ObjectRegistry::getRegistry()->addInstance('controller', $this); + ObjectRegistry::getRegistry('generic')->addInstance('controller', $this); } /** diff --git a/framework/main/classes/factories/client/class_ClientFactory.php b/framework/main/classes/factories/client/class_ClientFactory.php index 19248724..7b912e67 100644 --- a/framework/main/classes/factories/client/class_ClientFactory.php +++ b/framework/main/classes/factories/client/class_ClientFactory.php @@ -55,9 +55,9 @@ class ClientFactory extends BaseFactory { $registryKey = strtolower($protocolInstance->getProtocolName()) . '_client'; // Is the key already in registry? - if (ObjectRegistry::getRegistry()->instanceExists($registryKey)) { + if (ObjectRegistry::getRegistry('generic')->instanceExists($registryKey)) { // Then use that instance - $clientInstance = ObjectRegistry::getRegistry()->getInstance($registryKey); + $clientInstance = ObjectRegistry::getRegistry('generic')->getInstance($registryKey); // Set socket resource $clientInstance->setSocketResource($socketResource); @@ -66,7 +66,7 @@ class ClientFactory extends BaseFactory { $clientInstance = ObjectFactory::createObjectByConfiguredName($registryKey, array($socketResource)); // Set it in registry for later re-use - ObjectRegistry::getRegistry()->addInstance($registryKey, $clientInstance); + ObjectRegistry::getRegistry('generic')->addInstance($registryKey, $clientInstance); } // Return the prepared instance diff --git a/framework/main/classes/factories/database/class_DatabaseFrontendFactory.php b/framework/main/classes/factories/database/class_DatabaseFrontendFactory.php index 90ea3e2e..f5fc0bbd 100644 --- a/framework/main/classes/factories/database/class_DatabaseFrontendFactory.php +++ b/framework/main/classes/factories/database/class_DatabaseFrontendFactory.php @@ -49,7 +49,7 @@ class DatabaseFrontendFactory extends BaseFactory { */ public static final function createFrontendByConfiguredName (string $frontendName) { // Get registry instance - $registryInstance = ObjectRegistry::getRegistry(); + $registryInstance = ObjectRegistry::getRegistry('generic'); // Do we have an instance in the registry? if ($registryInstance->instanceExists($frontendName)) { diff --git a/framework/main/classes/factories/index/class_FileStackIndexFactory.php b/framework/main/classes/factories/index/class_FileStackIndexFactory.php index ad29daa3..e37beb90 100644 --- a/framework/main/classes/factories/index/class_FileStackIndexFactory.php +++ b/framework/main/classes/factories/index/class_FileStackIndexFactory.php @@ -57,15 +57,15 @@ class FileStackIndexFactory extends BaseFactory { if (empty($type)) { // Throw IAE throw new InvalidArgumentException('Parameter "type" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT); - } elseif (ObjectRegistry::getRegistry()->instanceExists($type . '_index')) { + } elseif (ObjectRegistry::getRegistry('generic')->instanceExists($type . '_index')) { // Get handler from registry - $indexInstance = ObjectRegistry::getRegistry()->getInstance($type . '_index'); + $indexInstance = ObjectRegistry::getRegistry('generic')->getInstance($type . '_index'); } else { // Get the handler instance $indexInstance = ObjectFactory::createObjectByConfiguredName($type . '_file_stack_index_class', [$fileInfoInstance]); // Add it to the registry - ObjectRegistry::getRegistry()->addInstance($type . '_index', $indexInstance); + ObjectRegistry::getRegistry('generic')->addInstance($type . '_index', $indexInstance); } // Return the instance diff --git a/framework/main/classes/factories/login/class_LoginFactory.php b/framework/main/classes/factories/login/class_LoginFactory.php index f668e726..dc668de0 100644 --- a/framework/main/classes/factories/login/class_LoginFactory.php +++ b/framework/main/classes/factories/login/class_LoginFactory.php @@ -49,7 +49,7 @@ class LoginFactory extends BaseFactory { */ public static final function createLoginObjectByRequest (Requestable $requestInstance) { // Get registry instance - $registryInstance = ObjectRegistry::getRegistry(); + $registryInstance = ObjectRegistry::getRegistry('generic'); // Do we have an instance in the registry? if ($registryInstance->instanceExists('login_helper')) { diff --git a/framework/main/classes/factories/registry/class_SocketRegistryFactory.php b/framework/main/classes/factories/registry/class_SocketRegistryFactory.php index 13cc619a..bed3dafa 100644 --- a/framework/main/classes/factories/registry/class_SocketRegistryFactory.php +++ b/framework/main/classes/factories/registry/class_SocketRegistryFactory.php @@ -49,7 +49,7 @@ class SocketRegistryFactory extends BaseFactory { */ public static final function createSocketRegistryInstance () { // Get registry instance - $registryInstance = ObjectRegistry::getRegistry(); + $registryInstance = ObjectRegistry::getRegistry('generic'); // Do we have an instance in the registry? if ($registryInstance->instanceExists('socket_registry')) { diff --git a/framework/main/classes/factories/stacks/class_FileStackFactory.php b/framework/main/classes/factories/stacks/class_FileStackFactory.php index 9691a6ed..92a5158b 100644 --- a/framework/main/classes/factories/stacks/class_FileStackFactory.php +++ b/framework/main/classes/factories/stacks/class_FileStackFactory.php @@ -73,15 +73,15 @@ class FileStackFactory extends BaseFactory { )); // If there is no handler? - if (ObjectRegistry::getRegistry()->instanceExists($stackName . '_stack')) { + if (ObjectRegistry::getRegistry('generic')->instanceExists($stackName . '_stack')) { // Get handler from registry - $stackInstance = ObjectRegistry::getRegistry()->getInstance($stackName . '_stack'); + $stackInstance = ObjectRegistry::getRegistry('generic')->getInstance($stackName . '_stack'); } else { // Get the handler instance $stackInstance = ObjectFactory::createObjectByConfiguredName($prefix . '_' . $stackName . '_stack_class', array($fileInfoInstance, $prefix . '_' . $stackName)); // Add it to the registry - ObjectRegistry::getRegistry()->addInstance($stackName . '_stack', $stackInstance); + ObjectRegistry::getRegistry('generic')->addInstance($stackName . '_stack', $stackInstance); } // Return the instance diff --git a/framework/main/classes/factories/user/class_UserFactory.php b/framework/main/classes/factories/user/class_UserFactory.php index 45821525..6fc42a6c 100644 --- a/framework/main/classes/factories/user/class_UserFactory.php +++ b/framework/main/classes/factories/user/class_UserFactory.php @@ -49,7 +49,7 @@ class UserFactory extends BaseFactory { */ public static final function createUserByRequest (Requestable $requestInstance) { // Get registry instance - $registryInstance = ObjectRegistry::getRegistry(); + $registryInstance = ObjectRegistry::getRegistry('generic'); // Do we have an instance in the registry? if ($registryInstance->instanceExists('user')) { diff --git a/framework/main/classes/factories/xml/class_XmlTemplateEngineFactory.php b/framework/main/classes/factories/xml/class_XmlTemplateEngineFactory.php index f6b5bda6..18b85097 100644 --- a/framework/main/classes/factories/xml/class_XmlTemplateEngineFactory.php +++ b/framework/main/classes/factories/xml/class_XmlTemplateEngineFactory.php @@ -63,9 +63,9 @@ class XmlTemplateEngineFactory extends BaseFactory { } // Do we have an instance in the registry? - if (ObjectRegistry::getRegistry()->instanceExists($configKey)) { + if (ObjectRegistry::getRegistry('generic')->instanceExists($configKey)) { // Then use this instance - $templateInstance = ObjectRegistry::getRegistry()->getInstance($configKey); + $templateInstance = ObjectRegistry::getRegistry('generic')->getInstance($configKey); } else { // Get the XML template instance $templateInstance = ObjectFactory::createObjectByConfiguredName($configKey); @@ -80,7 +80,7 @@ class XmlTemplateEngineFactory extends BaseFactory { $templateInstance->enableXmlCompacting(); // Set the instance in registry for further use - ObjectRegistry::getRegistry()->addInstance($configKey, $templateInstance); + ObjectRegistry::getRegistry('generic')->addInstance($configKey, $templateInstance); } // Return the instance diff --git a/framework/main/classes/filter/auth/class_UserAuthFilter.php b/framework/main/classes/filter/auth/class_UserAuthFilter.php index d909bd21..41d9b135 100644 --- a/framework/main/classes/filter/auth/class_UserAuthFilter.php +++ b/framework/main/classes/filter/auth/class_UserAuthFilter.php @@ -140,8 +140,8 @@ class UserAuthFilter extends BaseFilter implements Filterable { } // Remember auth and user instances in registry - ObjectRegistry::getRegistry()->addInstance('auth', $authInstance); - ObjectRegistry::getRegistry()->addInstance('user', $userInstance); + ObjectRegistry::getRegistry('generic')->addInstance('auth', $authInstance); + ObjectRegistry::getRegistry('generic')->addInstance('user', $userInstance); } } diff --git a/framework/main/classes/filter/change/class_EmailChangeFilter.php b/framework/main/classes/filter/change/class_EmailChangeFilter.php index 25e4729d..dcde36f1 100644 --- a/framework/main/classes/filter/change/class_EmailChangeFilter.php +++ b/framework/main/classes/filter/change/class_EmailChangeFilter.php @@ -114,7 +114,7 @@ class EmailChangeFilter extends BaseFilter implements Filterable { } // Now, get a user instance for comparison - $userInstance = ObjectRegistry::getRegistry()->getInstance('user'); + $userInstance = ObjectRegistry::getRegistry('generic')->getInstance('user'); // Get the email field $userEmail = $userInstance->getField('email'); diff --git a/framework/main/classes/filter/change/class_PasswordChangeFilter.php b/framework/main/classes/filter/change/class_PasswordChangeFilter.php index 8a011d07..4d878637 100644 --- a/framework/main/classes/filter/change/class_PasswordChangeFilter.php +++ b/framework/main/classes/filter/change/class_PasswordChangeFilter.php @@ -115,7 +115,7 @@ class PasswordChangeFilter extends BaseFilter implements Filterable { } // Now, get a user instance for comparison - $userInstance = ObjectRegistry::getRegistry()->getInstance('user'); + $userInstance = ObjectRegistry::getRegistry('generic')->getInstance('user'); // Update the "password" field DebugMiddleware::getSelfInstance()->partialStub('Unfinished part.'); diff --git a/framework/main/classes/filter/news/class_NewsDownloadFilter.php b/framework/main/classes/filter/news/class_NewsDownloadFilter.php index c4323697..0737f283 100644 --- a/framework/main/classes/filter/news/class_NewsDownloadFilter.php +++ b/framework/main/classes/filter/news/class_NewsDownloadFilter.php @@ -48,7 +48,7 @@ class NewsDownloadFilter extends BaseFilter implements Filterable { /** * Creates an instance of this filter class * - * @return $filterInstance An instance of this filter class + * @return $filterInstance An instance of this filter class */ public static final function createNewsDownloadFilter () { // Get a new instance @@ -70,7 +70,7 @@ class NewsDownloadFilter extends BaseFilter implements Filterable { $newsInstance = HtmlNewsFactory::createFactoryByRequest($requestInstance); // Store the news instance in registry - ObjectRegistry::getRegistry()->addInstance('news', $newsInstance); + ObjectRegistry::getRegistry('generic')->addInstance('news', $newsInstance); } } diff --git a/framework/main/classes/filter/payment/class_PaymentDiscoveryFilter.php b/framework/main/classes/filter/payment/class_PaymentDiscoveryFilter.php index c89e7d31..7299f4f7 100644 --- a/framework/main/classes/filter/payment/class_PaymentDiscoveryFilter.php +++ b/framework/main/classes/filter/payment/class_PaymentDiscoveryFilter.php @@ -123,7 +123,7 @@ class PaymentDiscoveryFilter extends BaseFilter implements Filterable { $discoveryInstance->discover($requestInstance); // Remember this instance if all wents fine - ObjectRegistry::getRegistry()->addInstance('payments', $discoveryInstance); + ObjectRegistry::getRegistry('generic')->addInstance('payments', $discoveryInstance); } catch (NoConfigEntryException $e) { // Something bad happend $requestInstance->setIsRequestValid(FALSE); diff --git a/framework/main/classes/filter/update/class_UserStatusConfimedUpdateFilter.php b/framework/main/classes/filter/update/class_UserStatusConfimedUpdateFilter.php index 5d2f1e35..e94a6ba0 100644 --- a/framework/main/classes/filter/update/class_UserStatusConfimedUpdateFilter.php +++ b/framework/main/classes/filter/update/class_UserStatusConfimedUpdateFilter.php @@ -66,7 +66,7 @@ class UserStatusConfimedUpdateFilter extends BaseFilter implements Filterable { */ public function execute (Requestable $requestInstance, Responseable $responseInstance) { // Get user instance from registry - $userInstance = ObjectRegistry::getRegistry()->getInstance('user'); + $userInstance = ObjectRegistry::getRegistry('generic')->getInstance('user'); // Get "confirmed" status from config $confirmed = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('user_status_confirmed'); diff --git a/framework/main/classes/filter/update/class_UserUpdateFilter.php b/framework/main/classes/filter/update/class_UserUpdateFilter.php index cf932497..ac688fd8 100644 --- a/framework/main/classes/filter/update/class_UserUpdateFilter.php +++ b/framework/main/classes/filter/update/class_UserUpdateFilter.php @@ -66,13 +66,13 @@ class UserUpdateFilter extends BaseFilter implements Filterable { */ public function execute (Requestable $requestInstance, Responseable $responseInstance) { // Get user instance from registry - $userInstance = ObjectRegistry::getRegistry()->getInstance('user'); + $userInstance = ObjectRegistry::getRegistry('generic')->getInstance('user'); // Now update last activity $userInstance->updateLastActivity($requestInstance); // Update auth data as well - $authInstance = ObjectRegistry::getRegistry()->getInstance('auth'); + $authInstance = ObjectRegistry::getRegistry('generic')->getInstance('auth'); $authInstance->updateAuthData(); // Write all updates to the database diff --git a/framework/main/classes/filter/validator/class_EmailValidatorFilter.php b/framework/main/classes/filter/validator/class_EmailValidatorFilter.php index ab07e8c0..01b631d6 100644 --- a/framework/main/classes/filter/validator/class_EmailValidatorFilter.php +++ b/framework/main/classes/filter/validator/class_EmailValidatorFilter.php @@ -151,7 +151,7 @@ class EmailValidatorFilter extends BaseFilter implements Filterable { $userInstance = NULL; // Get a registry instance - $registryInstance = ObjectRegistry::getRegistry(); + $registryInstance = ObjectRegistry::getRegistry('generic'); // Is the user already there? if ($registryInstance->instanceExists('user')) { diff --git a/framework/main/classes/filter/validator/class_UserNameValidatorFilter.php b/framework/main/classes/filter/validator/class_UserNameValidatorFilter.php index 10bb7f48..27be04c1 100644 --- a/framework/main/classes/filter/validator/class_UserNameValidatorFilter.php +++ b/framework/main/classes/filter/validator/class_UserNameValidatorFilter.php @@ -117,7 +117,7 @@ class UserNameValidatorFilter extends BaseFilter implements Filterable { $userInstance = NULL; // Get a registry instance - $registryInstance = ObjectRegistry::getRegistry(); + $registryInstance = ObjectRegistry::getRegistry('generic'); // Is the user already there? if ($registryInstance->instanceExists('user')) { diff --git a/framework/main/classes/filter/verifier/class_AccountPasswordVerifierFilter.php b/framework/main/classes/filter/verifier/class_AccountPasswordVerifierFilter.php index d06c8211..6369652f 100644 --- a/framework/main/classes/filter/verifier/class_AccountPasswordVerifierFilter.php +++ b/framework/main/classes/filter/verifier/class_AccountPasswordVerifierFilter.php @@ -103,7 +103,7 @@ class AccountPasswordVerifierFilter extends BaseFilter implements Filterable { } // Get a user instance - $userInstance = ObjectRegistry::getRegistry()->getInstance('user'); + $userInstance = ObjectRegistry::getRegistry('generic')->getInstance('user'); // Get current hash $currentHash = $userInstance->getField('pass_hash'); diff --git a/framework/main/classes/filter/verifier/class_ConfirmCodeVerifierFilter.php b/framework/main/classes/filter/verifier/class_ConfirmCodeVerifierFilter.php index 785665fe..2c4316a7 100644 --- a/framework/main/classes/filter/verifier/class_ConfirmCodeVerifierFilter.php +++ b/framework/main/classes/filter/verifier/class_ConfirmCodeVerifierFilter.php @@ -91,7 +91,7 @@ class ConfirmCodeVerifierFilter extends BaseFilter implements Filterable { } // Get a user instance from registry - $userInstance = ObjectRegistry::getRegistry()->getInstance('user'); + $userInstance = ObjectRegistry::getRegistry('generic')->getInstance('user'); // Get the confirm code from user for comparison $userCode = $userInstance->getField(UserDatabaseFrontend::DB_COLUMN_CONFIRM_HASH); diff --git a/framework/main/classes/filter/verifier/class_UserGuestVerifierFilter.php b/framework/main/classes/filter/verifier/class_UserGuestVerifierFilter.php index 21fcd217..e1f087d5 100644 --- a/framework/main/classes/filter/verifier/class_UserGuestVerifierFilter.php +++ b/framework/main/classes/filter/verifier/class_UserGuestVerifierFilter.php @@ -119,7 +119,7 @@ class UserGuestVerifierFilter extends BaseFilter implements Filterable { $userInstance = NULL; // Get a registry instance - $registryInstance = ObjectRegistry::getRegistry(); + $registryInstance = ObjectRegistry::getRegistry('generic'); // Is the user already there? if ($registryInstance->instanceExists('user')) { diff --git a/framework/main/classes/filter/verifier/class_UserNameVerifierFilter.php b/framework/main/classes/filter/verifier/class_UserNameVerifierFilter.php index 49562ac4..cdd08a1a 100644 --- a/framework/main/classes/filter/verifier/class_UserNameVerifierFilter.php +++ b/framework/main/classes/filter/verifier/class_UserNameVerifierFilter.php @@ -117,7 +117,7 @@ class UserNameVerifierFilter extends BaseFilter implements Filterable { $userInstance = NULL; // Get a registry instance - $registryInstance = ObjectRegistry::getRegistry(); + $registryInstance = ObjectRegistry::getRegistry('generic'); // Is the user already there? if ($registryInstance->instanceExists('user')) { diff --git a/framework/main/classes/filter/verifier/class_UserStatusVerifierFilter.php b/framework/main/classes/filter/verifier/class_UserStatusVerifierFilter.php index 44f53244..b025f5d0 100644 --- a/framework/main/classes/filter/verifier/class_UserStatusVerifierFilter.php +++ b/framework/main/classes/filter/verifier/class_UserStatusVerifierFilter.php @@ -65,7 +65,7 @@ class UserStatusVerifierFilter extends BaseFilter implements Filterable { */ public function execute (Requestable $requestInstance, Responseable $responseInstance) { // Get a user instance for comparison - $userInstance = ObjectRegistry::getRegistry()->getInstance('user'); + $userInstance = ObjectRegistry::getRegistry('generic')->getInstance('user'); // Is the user account confirmed? if ((!$userInstance->isConfirmed()) && (!$userInstance->isGuest()) && ($requestInstance->getRequestElement('action') != FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('action_status_problem'))) { diff --git a/framework/main/classes/filter/verifier/class_UserUnconfirmedVerifierFilter.php b/framework/main/classes/filter/verifier/class_UserUnconfirmedVerifierFilter.php index 53330065..46ea0c1f 100644 --- a/framework/main/classes/filter/verifier/class_UserUnconfirmedVerifierFilter.php +++ b/framework/main/classes/filter/verifier/class_UserUnconfirmedVerifierFilter.php @@ -94,7 +94,7 @@ class UserUnconfirmedVerifierFilter extends BaseFilter implements Filterable { } // Add this instance to registry - ObjectRegistry::getRegistry()->addInstance('user', $userInstance); + ObjectRegistry::getRegistry('generic')->addInstance('user', $userInstance); } } diff --git a/framework/main/classes/helper/class_BaseHelper.php b/framework/main/classes/helper/class_BaseHelper.php index 4dfac8f3..5c6ab752 100644 --- a/framework/main/classes/helper/class_BaseHelper.php +++ b/framework/main/classes/helper/class_BaseHelper.php @@ -263,7 +263,7 @@ abstract class BaseHelper extends BaseFrameworkSystem { try { // Get the required instance - $this->valueInstance = ObjectRegistry::getRegistry()->getInstance($registryKey); + $this->valueInstance = ObjectRegistry::getRegistry('generic')->getInstance($registryKey); } catch (NullPointerException $e) { // Not set in registry //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-HELPER: registryKey=%s returned no instance (NPE thrown)', $registryKey)); @@ -274,7 +274,7 @@ abstract class BaseHelper extends BaseFrameworkSystem { if (!is_null($extraKey)) { try { // Get the extra instance. - $this->extraInstance = ObjectRegistry::getRegistry()->getInstance($extraKey); + $this->extraInstance = ObjectRegistry::getRegistry('generic')->getInstance($extraKey); } catch (NullPointerException $e) { // Try to create it //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-HELPER: extraKey=%s returned no instance (NPE thrown), this->valueInstance[]=%s', $extraKey, gettype($this->valueInstance))); diff --git a/framework/main/classes/helper/html/forms/class_HtmlFormHelper.php b/framework/main/classes/helper/html/forms/class_HtmlFormHelper.php index 5db5e041..967ad93f 100644 --- a/framework/main/classes/helper/html/forms/class_HtmlFormHelper.php +++ b/framework/main/classes/helper/html/forms/class_HtmlFormHelper.php @@ -693,7 +693,7 @@ class HtmlFormHelper extends BaseHtmlHelper implements HelpableTemplate { try { // Get last executed pre filter - $extraInstance = ObjectRegistry::getRegistry()->getInstance('extra'); + $extraInstance = ObjectRegistry::getRegistry('generic')->getInstance('extra'); } catch (NullPointerException $e) { // Instance in registry is not set (NULL) // @TODO We need to log this later diff --git a/framework/main/classes/registry/class_ b/framework/main/classes/registry/class_ index 3bb75f74..a4ffbcbc 100644 --- a/framework/main/classes/registry/class_ +++ b/framework/main/classes/registry/class_ @@ -32,7 +32,7 @@ class ???Registry extends BaseRegistry implements Register { /** * Instance of this class */ - private static $registryInstance = null; + private static $registryInstances = []; /** * Protected constructor @@ -50,15 +50,15 @@ class ???Registry extends BaseRegistry implements Register { * * @return $registryInstance Instance of this class */ - public final static function getRegistry () { + public final static function getRegistry (string $key) { // Is an instance there? - if (is_null(self::$registryInstance)) { + if (is_null(self::$registryInstances[$key])) { // Not yet, so create one - self::$registryInstance = new ???Registry(); + self::$registryInstances[$key] = new ???Registry(); } // Return the instance - return self::$registryInstance; + return self::$registryInstances[$key]; } } diff --git a/framework/main/classes/registry/generic/class_GenericRegistry.php b/framework/main/classes/registry/generic/class_GenericRegistry.php index 21c94414..5c2b3a01 100644 --- a/framework/main/classes/registry/generic/class_GenericRegistry.php +++ b/framework/main/classes/registry/generic/class_GenericRegistry.php @@ -45,17 +45,28 @@ class GenericRegistry extends BaseRegistry implements Register { * Singleton getter for self instance. This class has no factory pattern * because here is no need for special parameters. * + * @param $key Key for for this instance * @return $registryInstance Instance of this class + * @throws InvalidArgumentException If a parameter has an invalid value */ - public static final function getRegistry () { + public static final function getRegistry (string $key) { + // Check parameter + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('OBJECT-REGISTRY: key=%s - CALLED!', $key)); + if (empty($key)) { + // Throw IAE + throw new InvalidArgumentException('Parameter "key" is empty'); + } + // Is an instance there? - if (is_null(self::$registryInstance)) { + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('OBJECT-REGISTRY: self::registryInstance[%s][]=%s', $key, gettype(self::$registryInstances[$key]))); + if (is_null(self::$registryInstances[$key])) { // Not yet, so create one - self::$registryInstance = new GenericRegistry(); + self::$registryInstances[$key] = new ObjectRegistry(); } // Return the instance - return self::$registryInstance; + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('OBJECT-REGISTRY: self::registryInstance[%s]=%s - EXIT!', $key, self::$registryInstances[$key]->__toString())); + return self::$registryInstances[$key]; } } diff --git a/framework/main/classes/registry/object/class_ObjectRegistry.php b/framework/main/classes/registry/object/class_ObjectRegistry.php index a5b7aa9a..b3c810c9 100644 --- a/framework/main/classes/registry/object/class_ObjectRegistry.php +++ b/framework/main/classes/registry/object/class_ObjectRegistry.php @@ -35,9 +35,9 @@ use \InvalidArgumentException; */ class ObjectRegistry extends BaseRegistry implements ObjectRegister { /** - * Instance of this class + * Instances of this class */ - private static $registryInstance = NULL; + private static $registryInstances = []; /** * Protected constructor @@ -61,17 +61,28 @@ class ObjectRegistry extends BaseRegistry implements ObjectRegister { * Singleton getter for self instance. This class has no factory pattern * because here is no need for special parameters. * + * @param $key Key for for this instance * @return $registryInstance Instance of this class + * @throws InvalidArgumentException If a parameter has an invalid value */ - public static final function getRegistry () { + public static final function getRegistry (string $key) { + // Check parameter + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('OBJECT-REGISTRY: key=%s - CALLED!', $key)); + if (empty($key)) { + // Throw IAE + throw new InvalidArgumentException('Parameter "key" is empty'); + } + // Is an instance there? - if (is_null(self::$registryInstance)) { + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('OBJECT-REGISTRY: self::registryInstance[%s][]=%s', $key, gettype(self::$registryInstances[$key]))); + if (is_null(self::$registryInstances[$key])) { // Not yet, so create one - self::$registryInstance = new ObjectRegistry(); + self::$registryInstances[$key] = new ObjectRegistry(); } // Return the instance - return self::$registryInstance; + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('OBJECT-REGISTRY: self::registryInstance[%s]=%s - EXIT!', $key, self::$registryInstances[$key]->__toString())); + return self::$registryInstances[$key]; } /** diff --git a/framework/main/tests/commands/console/class_TestsConsoleMainCommand.php b/framework/main/tests/commands/console/class_TestsConsoleMainCommand.php index d8fc1a1c..c4072c88 100644 --- a/framework/main/tests/commands/console/class_TestsConsoleMainCommand.php +++ b/framework/main/tests/commands/console/class_TestsConsoleMainCommand.php @@ -74,7 +74,7 @@ class TestsConsoleMainCommand extends BaseCommand implements Commandable { self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('MAIN: --- Starting tests ... ---'); // Get controller - $controllerInstance = ObjectRegistry::getRegistry()->getInstance('controller'); + $controllerInstance = ObjectRegistry::getRegistry('generic')->getInstance('controller'); // Run all tests $controllerInstance->executeTestsFilters($requestInstance, $responseInstance);