Skip to content

Commit 4acb240

Browse files
committed
Merge pull request #336 from andrey1s/repo
[orm][bug] fix create contentId by Object
2 parents 57b923a + 51b1341 commit 4acb240

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

Doctrine/Orm/ContentRepository.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,14 @@ public function getContentId($content)
6060
}
6161

6262
try {
63-
$meta = $this->getObjectManager()->getClassMetadata(get_class($content));
63+
$class = get_class($content);
64+
$meta = $this->getObjectManager()->getClassMetadata($class);
6465
$ids = $meta->getIdentifierValues($content);
65-
if (0 !== count($ids)) {
66-
throw new \Exception('Multi identifier values not supported in '.get_class($content));
66+
if (1 !== count($ids)) {
67+
throw new \Exception(sprintf('Class "%s" must use only one identifier', $class));
6768
}
6869

69-
return implode(':', array(
70-
get_class($content),
71-
reset($ids),
72-
));
70+
return implode(':', array($class, reset($ids)));
7371
} catch (\Exception $e) {
7472
return;
7573
}

0 commit comments

Comments
 (0)