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