From: Roland Häder Date: Mon, 14 May 2012 20:04:13 +0000 (+0000) Subject: 'core' enchanced: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=117d173431deee77c866ef224d444212d36995bd;p=core.git 'core' enchanced: Method BaseRegistry::getRegistryKeyFromArray() added which allows to generate prefixed registry keys from arrays. This does mostly call implode() with a standard glue. --- diff --git a/inc/classes/main/registry/class_BaseRegistry.php b/inc/classes/main/registry/class_BaseRegistry.php index 200ea171..96f94897 100644 --- a/inc/classes/main/registry/class_BaseRegistry.php +++ b/inc/classes/main/registry/class_BaseRegistry.php @@ -22,6 +22,11 @@ * along with this program. If not, see . */ class BaseRegistry extends BaseFrameworkSystem implements Registerable { + /** + * Glue for generating a registry key + */ + const REGISTRY_KEY_GLUE = '_'; + /** * Instance of this class */ @@ -180,6 +185,23 @@ class BaseRegistry extends BaseFrameworkSystem implements Registerable { // Return the result return $objectInstance; } + + /** + * "Getter" for a registry key for given prefix and array. This method + * calls implode() to get a suitable key. This method does not care about + * the indexes. + * + * @param $prefix Prefix for the key + * @param $data An array with data + * @return $registryKey A registry key + */ + protected function getRegistryKeyFromArray ($prefix, array $data) { + // "Generate" the key + $registryKey = $prefix . self::REGISTRY_KEY_GLUE . implode(self::REGISTRY_KEY_GLUE, $data); + + // Return it + return $registryKey; + } } // [EOF]