Skip to content

Commit 345e816

Browse files
committed
Fix Hydra doc when the ID is readonly
1 parent b1234a9 commit 345e816

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

Mapping/Loader/DoctrineIdentifierLoader.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ public function loadClassMetadata(
4848
return true;
4949
}
5050

51-
$doctrineClassMetaData = $manager->getClassMetadata($className);
52-
if (!$doctrineClassMetaData) {
51+
$doctrineClassMetadata = $manager->getClassMetadata($className);
52+
if (!$doctrineClassMetadata) {
5353
return true;
5454
}
5555

56-
$identifiers = $doctrineClassMetaData->getIdentifier();
56+
$identifiers = $doctrineClassMetadata->getIdentifier();
5757
if (1 !== count($identifiers)) {
5858
return true;
5959
}
@@ -63,6 +63,10 @@ public function loadClassMetadata(
6363
if ($attribute->getName() === $identifierName) {
6464
$attribute->setIdentifier(true);
6565

66+
if (!$doctrineClassMetadata->isIdentifierNatural()) {
67+
$attribute->setWritable(false);
68+
}
69+
6670
return true;
6771
}
6872
}

0 commit comments

Comments
 (0)