* @return void
*/
public final function setWebOutputInstance (OutputStreamer $webInstance) {
- ObjectRegistry::getRegistry()->addInstance('web_output', $webInstance);
+ ObjectRegistry::getRegistry('generic')->addInstance('web_output', $webInstance);
}
/**
* @return $webOutputInstance - Instance to class WebOutput
*/
public final function getWebOutputInstance () {
- return ObjectRegistry::getRegistry()->getInstance('web_output');
+ return ObjectRegistry::getRegistry('generic')->getInstance('web_output');
}
/**
// 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');
*/
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) {
$actionInstance->addExtraFilters($controllerInstance, $requestInstance);
// Remember this action in registry
- ObjectRegistry::getRegistry()->addInstance('action', $actionInstance);
+ ObjectRegistry::getRegistry('generic')->addInstance('action', $actionInstance);
}
}
*/
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();
*/
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();
*/
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();
$this->initFilterChain(self::FILTER_CHAIN_POST_COMMAND);
// Add this controller to the registry
- ObjectRegistry::getRegistry()->addInstance('controller', $this);
+ ObjectRegistry::getRegistry('generic')->addInstance('controller', $this);
}
/**
$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);
$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
*/
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)) {
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
*/
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')) {
*/
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')) {
));
// 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
*/
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')) {
}
// 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);
$templateInstance->enableXmlCompacting();
// Set the instance in registry for further use
- ObjectRegistry::getRegistry()->addInstance($configKey, $templateInstance);
+ ObjectRegistry::getRegistry('generic')->addInstance($configKey, $templateInstance);
}
// Return the instance
}
// 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);
}
}
}
// 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');
}
// 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.');
/**
* 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
$newsInstance = HtmlNewsFactory::createFactoryByRequest($requestInstance);
// Store the news instance in registry
- ObjectRegistry::getRegistry()->addInstance('news', $newsInstance);
+ ObjectRegistry::getRegistry('generic')->addInstance('news', $newsInstance);
}
}
$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);
*/
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');
*/
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
$userInstance = NULL;
// Get a registry instance
- $registryInstance = ObjectRegistry::getRegistry();
+ $registryInstance = ObjectRegistry::getRegistry('generic');
// Is the user already there?
if ($registryInstance->instanceExists('user')) {
$userInstance = NULL;
// Get a registry instance
- $registryInstance = ObjectRegistry::getRegistry();
+ $registryInstance = ObjectRegistry::getRegistry('generic');
// Is the user already there?
if ($registryInstance->instanceExists('user')) {
}
// Get a user instance
- $userInstance = ObjectRegistry::getRegistry()->getInstance('user');
+ $userInstance = ObjectRegistry::getRegistry('generic')->getInstance('user');
// Get current hash
$currentHash = $userInstance->getField('pass_hash');
}
// 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);
$userInstance = NULL;
// Get a registry instance
- $registryInstance = ObjectRegistry::getRegistry();
+ $registryInstance = ObjectRegistry::getRegistry('generic');
// Is the user already there?
if ($registryInstance->instanceExists('user')) {
$userInstance = NULL;
// Get a registry instance
- $registryInstance = ObjectRegistry::getRegistry();
+ $registryInstance = ObjectRegistry::getRegistry('generic');
// Is the user already there?
if ($registryInstance->instanceExists('user')) {
*/
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'))) {
}
// Add this instance to registry
- ObjectRegistry::getRegistry()->addInstance('user', $userInstance);
+ ObjectRegistry::getRegistry('generic')->addInstance('user', $userInstance);
}
}
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));
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)));
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
/**
* Instance of this class
*/
- private static $registryInstance = null;
+ private static $registryInstances = [];
/**
* Protected constructor
*
* @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];
}
}
* 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];
}
}
*/
class ObjectRegistry extends BaseRegistry implements ObjectRegister {
/**
- * Instance of this class
+ * Instances of this class
*/
- private static $registryInstance = NULL;
+ private static $registryInstances = [];
/**
* Protected constructor
* 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];
}
/**
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);