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