-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[2.2] [Form] Added form type "entity_identifier" (#1946) #1951
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
05a064a
662691a
4a62fc3
6f11075
0802d83
295bd6d
38713e2
fc400f5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,7 +34,7 @@ class OneEntityToIdTransformer implements DataTransformerInterface | |
public function __construct(EntityManager $em, $class, $property, $queryBuilder) | ||
{ | ||
if (null !== $queryBuilder && ! $queryBuilder instanceof \Closure) { | ||
throw new UnexpectedTypeException($queryBuilder, 'Doctrine\ORM\QueryBuilder or \Closure'); | ||
throw new UnexpectedTypeException($queryBuilder, '\Closure'); | ||
} | ||
|
||
if (null === $class) { | ||
|
@@ -84,10 +84,8 @@ public function reverseTransform($data) | |
$repository = $em->getRepository($this->class); | ||
|
||
if ($qb = $this->queryBuilder) { | ||
// If a closure was passed, call id with the repository and the id | ||
if ($qb instanceof \Closure) { | ||
$qb = $qb($repository, $data); | ||
} | ||
// Call the closure with the repository and the id | ||
$qb = $qb($repository, $data); | ||
|
||
try { | ||
$result = $qb->getQuery()->getSingleResult(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this does not make sense in the case where a QueryBuilder is passed directly as it does not receive the data at all There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah sorry, looking at the constructor, the |
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use getOneOrNullResult?