class IdReader{ private ObjectManager
$om;
private ClassMetadata
$classMetadata;
private bool
$singleId;
private bool
$intId;
private string
$idField;
private ?self
$associationIdReader = null;
public function __construct(ObjectManager
$om, ClassMetadata
$classMetadata) { $ids =
$classMetadata->
getIdentifierFieldNames();
$idType =
$classMetadata->
getTypeOfField(current($ids));
$this->om =
$om;
$this->classMetadata =
$classMetadata;
$this->singleId = 1 === \
count($ids);
$this->intId =
$this->singleId && \
in_array($idType,
['integer', 'smallint', 'bigint'
]);
$this->idField =
current($ids);
// single field association are resolved, since the schema column could be an int
if ($this->singleId &&
$classMetadata->
hasAssociation($this->idField
)) { $this->associationIdReader =
new self($om,
$om->
getClassMetadata(