Skip to content

Commit

Permalink
Add: Possibility to filter Doctrine Collections
Browse files Browse the repository at this point in the history
  • Loading branch information
BenjaminPaap committed Nov 20, 2017
1 parent 7da9451 commit ae50416
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Mapper/FieldFilter/ArrayObjectMappingFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace BCC\AutoMapperBundle\Mapper\FieldFilter;

use Doctrine\Common\Collections\Collection;

/**
* Filter array object value and map inner items to given className
*
Expand All @@ -19,6 +21,10 @@ class ArrayObjectMappingFilter extends AbstractMappingFilter
*/
function filter($value)
{
if ($value instanceof Collection) {
$value = $value->toArray();
}

if (is_array($value)) {
$objectFilter = new ObjectMappingFilter($this->className);
$objectFilter->setMapper($this->getMapper());
Expand All @@ -28,4 +34,4 @@ function filter($value)
}, $value);
}
}
}
}

0 comments on commit ae50416

Please sign in to comment.