From: Roland Häder Date: Mon, 2 Jun 2008 18:19:40 +0000 (+0000) Subject: Access level fixed, registry is able to return instances X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=7fa2fe6a7ae87c576c5251a78a9272f311c7e35d;p=shipsimu.git Access level fixed, registry is able to return instances --- diff --git a/inc/classes/main/filter/validator/class_EmailValidatorFilter.php b/inc/classes/main/filter/validator/class_EmailValidatorFilter.php index 8d9117b..37e207d 100644 --- a/inc/classes/main/filter/validator/class_EmailValidatorFilter.php +++ b/inc/classes/main/filter/validator/class_EmailValidatorFilter.php @@ -139,7 +139,7 @@ class EmailValidatorFilter extends BaseFrameworkSystem implements Filterable { $userInstance = null; // Get a registry instance - $registry = Registry::getInstance(); + $registry = Registry::getRegistry(); // Is the user already there? if ($registry->instanceExists('user')) { diff --git a/inc/classes/main/filter/validator/class_UserNameValidatorFilter.php b/inc/classes/main/filter/validator/class_UserNameValidatorFilter.php index 38471cd..85ddfbe 100644 --- a/inc/classes/main/filter/validator/class_UserNameValidatorFilter.php +++ b/inc/classes/main/filter/validator/class_UserNameValidatorFilter.php @@ -114,7 +114,7 @@ class UserNameValidatorFilter extends BaseFrameworkSystem implements Filterable $userInstance = null; // Get a registry instance - $registry = Registry::getInstance(); + $registry = Registry::getRegistry(); // Is the user already there? if ($registry->instanceExists('user')) { diff --git a/inc/classes/main/registry/class_Registry.php b/inc/classes/main/registry/class_Registry.php index 0ceda2c..3d3c8ca 100644 --- a/inc/classes/main/registry/class_Registry.php +++ b/inc/classes/main/registry/class_Registry.php @@ -57,7 +57,7 @@ class Registry extends BaseFrameworkSystem implements Register { * * @return $selfInstance Instance of this class */ - public final static function getInstance () { + public final static function getRegistry () { // Is an instance there? if (is_null(self::$selfInstance)) { // Not yet, so create one @@ -92,6 +92,25 @@ class Registry extends BaseFrameworkSystem implements Register { public function addInstance ($instanceKey, Registerable $objectInstance) { $this->instanceRegistry[$instanceKey] = $objectInstance; } + + /** + * Gets a registered instance or null if not found + * + * @param $instanceKey The key to identify the instance + * @return $objectInstance An instance we shall store + */ + public function getInstance ($instanceKey) { + // By default the instance is not in the registry + $objectInstance = null; + + // Is the instance there? + if ($this->instanceExists($instanceKey)) { + $objectInstance = $this->instanceRegistry[$instanceKey]; + } + + // Return the result + return $objectInstance; + } } // [EOF] diff --git a/inc/classes/main/user/class_User.php b/inc/classes/main/user/class_User.php index 05afd6d..564d0ec 100644 --- a/inc/classes/main/user/class_User.php +++ b/inc/classes/main/user/class_User.php @@ -145,7 +145,7 @@ class User extends BaseFrameworkSystem implements ManageableUser, Registerable { * * @return $exists Wether the username exists */ - protected function ifUsernameExists () { + public function ifUsernameExists () { // By default the username does exist $exists = true;