| @@ 108-125 (lines=18) @@ | ||
| 105 | /** |
|
| 106 | * {@inheritdoc} |
|
| 107 | */ |
|
| 108 | public function getIdentifier($object) |
|
| 109 | { |
|
| 110 | $objectFqn = ClassUtils::getRealClass(get_class($object)); |
|
| 111 | $metadata = $this->documentManager->getClassMetadata($objectFqn); |
|
| 112 | $uuidFieldName = $metadata->getUuidFieldName(); |
|
| 113 | ||
| 114 | if (!$uuidFieldName) { |
|
| 115 | throw new \RuntimeException(sprintf( |
|
| 116 | 'Document "%s" does not have a UUID-mapped property. All '. |
|
| 117 | 'PHPCR-ODM documents must have a mapped UUID proprety.', |
|
| 118 | $objectFqn |
|
| 119 | )); |
|
| 120 | } |
|
| 121 | ||
| 122 | $node = $this->documentManager->getNodeForDocument($object); |
|
| 123 | ||
| 124 | return $node->getIdentifier(); |
|
| 125 | } |
|
| 126 | ||
| 127 | /** |
|
| 128 | * {@inheritdoc} |
|
| @@ 130-145 (lines=16) @@ | ||
| 127 | /** |
|
| 128 | * {@inheritdoc} |
|
| 129 | */ |
|
| 130 | public function setParent($object, $parent) |
|
| 131 | { |
|
| 132 | $objectFqn = ClassUtils::getRealClass(get_class($object)); |
|
| 133 | $metadata = $this->documentManager->getClassMetadata($objectFqn); |
|
| 134 | $parentField = $metadata->parentMapping; |
|
| 135 | ||
| 136 | if (!$parentField) { |
|
| 137 | throw new \RuntimeException(sprintf( |
|
| 138 | 'Document "%s" does not have a ParentDocument mapping All '. |
|
| 139 | 'PHPCR-ODM documents must have a mapped parent proprety.', |
|
| 140 | $objectFqn |
|
| 141 | )); |
|
| 142 | } |
|
| 143 | ||
| 144 | $metadata->setFieldValue($object, $parentField, $parent); |
|
| 145 | } |
|
| 146 | ||
| 147 | /** |
|
| 148 | * {@inheritdoc} |
|