public function transform($collection)
    {
        if ($collection && !is_array($collection) && !($collection instanceof \ArrayAccess)) {
            // in case of single entity, we have to make sure it's managed
            if (!$this->er->getManager()->contains($collection)) {
                $collection = $this->er->getManager()->merge($collection);
            }
        }
        return $collection;
    }