mapper->getForm()->getComponentEntityFactory($component)) { $className = $this->mapper->getEntityManager()->getClassMetadata($meta->getAssociationTargetClass($component->getName()))->getName(); $relation = new $className(); if ($meta->getAssociationMapping($component->getName())['type'] === ClassMetadata::ONE_TO_MANY) { $relation->{'set' . (new ReflectionClass($entity))->getShortName()}($entity); } return $relation; } return $callback(); } }