| @@ 62-79 (lines=18) @@ | ||
| 59 | /** |
|
| 60 | * {@inheritdoc} |
|
| 61 | */ |
|
| 62 | public function getIdentifier($object) |
|
| 63 | { |
|
| 64 | $objectFqn = ClassUtils::getRealClass(get_class($object)); |
|
| 65 | $metadata = $this->documentManager->getClassMetadata($objectFqn); |
|
| 66 | $uuidFieldName = $metadata->getUuidFieldName(); |
|
| 67 | ||
| 68 | if (!$uuidFieldName) { |
|
| 69 | throw new \RuntimeException(sprintf( |
|
| 70 | 'Document "%s" does not have a UUID-mapped property. All '. |
|
| 71 | 'PHPCR-ODM documents must have a mapped UUID proprety.', |
|
| 72 | $objectFqn |
|
| 73 | )); |
|
| 74 | } |
|
| 75 | ||
| 76 | $node = $this->documentManager->getNodeForDocument($object); |
|
| 77 | ||
| 78 | return $node->getIdentifier(); |
|
| 79 | } |
|
| 80 | ||
| 81 | /** |
|
| 82 | * {@inheritdoc} |
|
| @@ 84-99 (lines=16) @@ | ||
| 81 | /** |
|
| 82 | * {@inheritdoc} |
|
| 83 | */ |
|
| 84 | public function setParent($object, $parent) |
|
| 85 | { |
|
| 86 | $objectFqn = ClassUtils::getRealClass(get_class($object)); |
|
| 87 | $metadata = $this->documentManager->getClassMetadata($objectFqn); |
|
| 88 | $parentField = $metadata->parentMapping; |
|
| 89 | ||
| 90 | if (!$parentField) { |
|
| 91 | throw new \RuntimeException(sprintf( |
|
| 92 | 'Document "%s" does not have a ParentDocument mapping All '. |
|
| 93 | 'PHPCR-ODM documents must have a mapped parent proprety.', |
|
| 94 | $objectFqn |
|
| 95 | )); |
|
| 96 | } |
|
| 97 | ||
| 98 | $metadata->setFieldValue($object, $parentField, $parent); |
|
| 99 | } |
|
| 100 | ||
| 101 | /** |
|
| 102 | * {@inheritdoc} |
|