From 117d173431deee77c866ef224d444212d36995bd Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Mon, 14 May 2012 20:04:13 +0000 Subject: [PATCH] 'core' enchanced: Method BaseRegistry::getRegistryKeyFromArray() added which allows to generate prefixed registry keys from arrays. This does mostly call implode() with a standard glue. --- .../main/registry/class_BaseRegistry.php | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) 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] -- 2.39.2