if (!
$constraint instanceof EntityNotExists
) { throw new UnexpectedTypeException($constraint, EntityNotExists::
class);
} if ($value === null ||
$value === ''
) { return;
} $definition =
$this->definitionRegistry->
getByEntityName($constraint->
getEntity());
$criteria =
clone $constraint->
getCriteria();
$criteria->
addFilter(new EqualsFilter($constraint->
getPrimaryProperty(),
$value));
// Only one entity is enough to determine existence.
// As the property can be set in the constraint, the search above does not necessarily return just one entity.
$criteria->
setLimit(1
);
$result =
$this->entitySearcher->
search($definition,
$criteria,
$constraint->
getContext());
if ($result->
getTotal() <= 0
) { return;
}