/** * @param Field $field * @param DataObjectInterface $object * @throws ConfigException */ public function handleField(Field $field, DataObjectInterface $object) { if (!$field->getValue()) { return; } $this->setDefaultOptions($field); $options = $field->getOptions(); /** @var ObjectManager $objectManager */ $objectManager = $options['em']; $class = $options['class']; if (!($repo = $objectManager->getRepository($class))) { throw new ConfigException(sprintf('Repository for class \'%s\' doesn\'t exist.', $class)); } $property = $options['property']; $criteria = array($property => $field->getValue()); $entity = $repo->findOneBy($criteria); $field->setValue($entity); }