Skip to content

Commit ae50416

Browse files
committed
Add: Possibility to filter Doctrine Collections
1 parent 7da9451 commit ae50416

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Mapper/FieldFilter/ArrayObjectMappingFilter.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace BCC\AutoMapperBundle\Mapper\FieldFilter;
44

5+
use Doctrine\Common\Collections\Collection;
6+
57
/**
68
* Filter array object value and map inner items to given className
79
*
@@ -19,6 +21,10 @@ class ArrayObjectMappingFilter extends AbstractMappingFilter
1921
*/
2022
function filter($value)
2123
{
24+
if ($value instanceof Collection) {
25+
$value = $value->toArray();
26+
}
27+
2228
if (is_array($value)) {
2329
$objectFilter = new ObjectMappingFilter($this->className);
2430
$objectFilter->setMapper($this->getMapper());
@@ -28,4 +34,4 @@ function filter($value)
2834
}, $value);
2935
}
3036
}
31-
}
37+
}

0 commit comments

Comments
 (0)