Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Set rootIdentifierMethod when identifier-method is defined for a tree… #2694

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion schemas/orm/doctrine-extensions-mapping-2-1.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ people to push their own additional attributes/elements into the same field elem
<xs:element name="tree-left" type="gedmo:emptyType"/>
<xs:element name="tree-right" type="gedmo:emptyType"/>
<xs:element name="tree-level" type="gedmo:emptyType"/>
<xs:element name="tree-root" type="gedmo:emptyType"/>
<!-- many-to-one -->
<!-- xs:element name="versioned" type="gedmo:emptyType"/-->
<xs:element name="tree-parent" type="gedmo:emptyType"/>
Expand Down Expand Up @@ -163,4 +162,7 @@ people to push their own additional attributes/elements into the same field elem
</xs:restriction>
</xs:simpleType>

<xs:complexType name="tree-root">
<xs:attribute name="identifier-method" type="xs:string" use="optional" />
</xs:complexType>
</xs:schema>
4 changes: 3 additions & 1 deletion schemas/orm/doctrine-extensions-mapping-2-2.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
<xs:element name="tree-left" type="gedmo:emptyType"/>
<xs:element name="tree-right" type="gedmo:emptyType"/>
<xs:element name="tree-level" type="gedmo:emptyType"/>
<xs:element name="tree-root" type="gedmo:emptyType"/>
<xs:element name="tree-parent" type="gedmo:emptyType"/>
<xs:element name="tree-path-source" type="gedmo:emptyType"/>
<xs:element name="tree-lock-time" type="gedmo:emptyType"/>
Expand Down Expand Up @@ -185,4 +184,7 @@
<xs:attribute name="disallowed-types" type="xs:string" use="optional" />
</xs:complexType>

<xs:complexType name="tree-root">
<xs:attribute name="identifier-method" type="xs:string" use="optional" />
</xs:complexType>
</xs:schema>
5 changes: 5 additions & 0 deletions src/Tree/Mapping/Driver/Xml.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,11 @@
throw new InvalidMappingException("Unable to find root descendant relation through root field - [{$field}] in class - {$meta->getName()}");
}
$config['root'] = $field;

$identifierMethod = $this->_getAttribute($manyToOneMapping->{'tree-root'}, 'identifier-method');
if (!empty($identifierMethod)) {
$config['rootIdentifierMethod'] = $this->_getAttribute($manyToOneMapping->{'tree-root'}, 'identifier-method');

Check warning on line 219 in src/Tree/Mapping/Driver/Xml.php

View check run for this annotation

Codecov / codecov/patch

src/Tree/Mapping/Driver/Xml.php#L217-L219

Added lines #L217 - L219 were not covered by tests
}
}
}
}
Expand Down