From 5ba9f99cf983cdf9847302b5eaf28c8b45058310 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Thu, 16 May 2013 19:41:51 -0400 Subject: [PATCH] CRM_Utils_Migrate_Export - Add toArray() Unlike toXML(), this can be used with alternative serializations like json_encode() or var_export() --- CRM/Utils/Migrate/Export.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/CRM/Utils/Migrate/Export.php b/CRM/Utils/Migrate/Export.php index 15ef28803c..e1f5105f56 100644 --- a/CRM/Utils/Migrate/Export.php +++ b/CRM/Utils/Migrate/Export.php @@ -287,6 +287,21 @@ class CRM_Utils_Migrate_Export { return $buffer; } + /** + * Generate an array-tree representation of the exported elements. + * + * @return array + */ + function toArray() { + $result = array(); + foreach (array_keys($this->_xml) as $key) { + if (!empty($this->_xml[$key]['data'])) { + $result[ $this->_xml[$key]['name'] ] = $this->_xml[$key]['data']; + } + } + return $result; + } + function fetch($groupName, $daoName, $sql = NULL) { $idNameFields = isset($this->_xml[$groupName]['idNameFields']) ? $this->_xml[$groupName]['idNameFields'] : NULL; $mappedFields = isset($this->_xml[$groupName]['mappedFields']) ? $this->_xml[$groupName]['mappedFields'] : NULL; -- 2.25.1