From: Roland Haeder Date: Sun, 9 Feb 2014 02:56:32 +0000 (+0100) Subject: Added removeNonPublicDataFromArray(). X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=b76edd7b7d13db3fc266419eb1ddfdb73adeab1e;p=core.git Added removeNonPublicDataFromArray(). Signed-off-by: Roland Häder --- diff --git a/inc/classes/interfaces/database/backend/class_DatabaseBackend.php b/inc/classes/interfaces/database/backend/class_DatabaseBackend.php index ca679722..287cb267 100644 --- a/inc/classes/interfaces/database/backend/class_DatabaseBackend.php +++ b/inc/classes/interfaces/database/backend/class_DatabaseBackend.php @@ -62,6 +62,14 @@ interface DatabaseBackend extends FrameworkDatabase { * @throws SqlException If an SQL error occurs */ function queryUpdateDataSet (StoreableCriteria $dataSetInstance); + + /** + * Removes non-public data from given array. + * + * @param $data An array with possible non-public data that needs to be removed. + * @return $data A cleaned up array with only public data. + */ + function removeNonPublicDataFromArray (array $data); } // [EOF] diff --git a/inc/classes/main/database/class_BaseDatabaseBackend.php b/inc/classes/main/database/class_BaseDatabaseBackend.php index 5c0d29be..07d1b33b 100644 --- a/inc/classes/main/database/class_BaseDatabaseBackend.php +++ b/inc/classes/main/database/class_BaseDatabaseBackend.php @@ -83,6 +83,14 @@ abstract class BaseDatabaseBackend extends BaseFrameworkSystem implements Databa protected final function resetLastException () { $this->lastException = NULL; } + + /** + * Removes non-public data from given array. + * + * @param $data An array with possible non-public data that needs to be removed. + * @return $data A cleaned up array with only public data. + */ + public abstract function removeNonPublicDataFromArray(array $data); } // [EOF] diff --git a/inc/classes/main/database/databases/class_LocalFileDatabase.php b/inc/classes/main/database/databases/class_LocalFileDatabase.php index 445b7f8d..7fd9e90c 100644 --- a/inc/classes/main/database/databases/class_LocalFileDatabase.php +++ b/inc/classes/main/database/databases/class_LocalFileDatabase.php @@ -596,6 +596,21 @@ class LocalFileDatabase extends BaseDatabaseBackend implements DatabaseBackend { // Return the column return $primaryKey; } + + /** + * Removes non-public data from given array. + * + * @param $data An array with possible non-public data that needs to be removed. + * @return $data A cleaned up array with only public data. + * @todo Add more generic non-public data for removal + */ + public function removeNonPublicDataFromArray (array $data) { + // Remove '__idx' + unset($data[$this->indexKey]); + + // Return it + return $data; + } } // [EOF]