From 33a2da595eae58c152ac1190b284fee699532bec Mon Sep 17 00:00:00 2001 From: Kit Sunde Date: Fri, 31 Jul 2015 01:26:24 +0800 Subject: [PATCH 1/2] Conditionally serialize foreign objects on collection toArray --- src/Propel/Runtime/Collection/ObjectCollection.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Propel/Runtime/Collection/ObjectCollection.php b/src/Propel/Runtime/Collection/ObjectCollection.php index 5d17d3a0d5..769e98ac48 100644 --- a/src/Propel/Runtime/Collection/ObjectCollection.php +++ b/src/Propel/Runtime/Collection/ObjectCollection.php @@ -160,7 +160,7 @@ public function fromArray($arr) * * @return array */ - public function toArray($keyColumn = null, $usePrefix = false, $keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array()) + public function toArray($keyColumn = null, $usePrefix = false, $keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) { $ret = array(); $keyGetterMethod = 'get' . $keyColumn; @@ -169,7 +169,7 @@ public function toArray($keyColumn = null, $usePrefix = false, $keyType = TableM foreach ($this->data as $key => $obj) { $key = null === $keyColumn ? $key : $obj->$keyGetterMethod(); $key = $usePrefix ? ($this->getModel() . '_' . $key) : $key; - $ret[$key] = $obj->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + $ret[$key] = $obj->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, $includeForeignObjects); } return $ret; From 9d6bc9c0ccb650706cb58b4f48ea55949ee956d0 Mon Sep 17 00:00:00 2001 From: Kit Sunde Date: Fri, 31 Jul 2015 01:34:26 +0800 Subject: [PATCH 2/2] Update PHPDocs for collection->toArray --- src/Propel/Runtime/Collection/ObjectCollection.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Propel/Runtime/Collection/ObjectCollection.php b/src/Propel/Runtime/Collection/ObjectCollection.php index 769e98ac48..dd3401515e 100644 --- a/src/Propel/Runtime/Collection/ObjectCollection.php +++ b/src/Propel/Runtime/Collection/ObjectCollection.php @@ -139,6 +139,7 @@ public function fromArray($arr) * TableMap::TYPE_NUM. Defaults to TableMap::TYPE_PHPNAME. * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. * * * $bookCollection->toArray();