Skip to content

Commit 673fb05

Browse files
committed
fix issue #1717
1 parent 9790b8d commit 673fb05

File tree

4 files changed

+27
-4
lines changed

4 files changed

+27
-4
lines changed

src/Metadata/Extractor/XmlExtractor.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ private function getProperties(\SimpleXMLElement $resource): array
122122
'subresource' => $property->subresource ? [
123123
'collection' => $this->phpize($property->subresource, 'collection', 'bool'),
124124
'resourceClass' => $this->phpize($property->subresource, 'resourceClass', 'string'),
125+
'maxDepth' => $this->phpize($property->subresource, 'maxDepth', 'integer'),
125126
] : null,
126127
];
127128
}
@@ -143,6 +144,8 @@ private function phpize(\SimpleXMLElement $array, string $key, string $type)
143144
switch ($type) {
144145
case 'string':
145146
return (string) $array[$key];
147+
case 'integer':
148+
return (integer) $array[$key];
146149
case 'bool':
147150
return (bool) XmlUtils::phpize($array[$key]);
148151
}

src/Metadata/Property/Factory/ExtractorPropertyMetadataFactory.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,13 +146,15 @@ private function createSubresourceMetadata($subresource, PropertyMetadata $prope
146146
if (null !== $type) {
147147
$isCollection = $type->isCollection();
148148
$resourceClass = $isCollection ? $type->getCollectionValueType()->getClassName() : $type->getClassName();
149+
$maxDepth = null; // for Type we can't configure maxDepth, maxDepth is always null
149150
} elseif (isset($subresource['resourceClass'])) {
150151
$resourceClass = $subresource['resourceClass'];
151152
$isCollection = $subresource['collection'] ?? true;
153+
$maxDepth = $subresource['maxDepth'] ?? null;
152154
} else {
153155
return null;
154156
}
155157

156-
return new SubresourceMetadata($resourceClass, $isCollection);
158+
return new SubresourceMetadata($resourceClass, $isCollection, $maxDepth);
157159
}
158160
}

tests/Metadata/Property/Factory/ExtractorPropertyMetadataFactoryTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public function testCreateWithParentPropertyMetadataFactoryYaml(PropertyMetadata
130130
}
131131

132132
/**
133-
* @dataProvider decoratedPropertyMetadataProvider
133+
* @dataProvider typedPropertyMetadataProvider
134134
*/
135135
public function testCreateWithCollectionTypedParentPropertyMetadataFactoryYaml(PropertyMetadata $expectedPropertyMetadata)
136136
{
@@ -161,7 +161,7 @@ public function testCreateWithCollectionTypedParentPropertyMetadataFactoryYaml(P
161161
}
162162

163163
/**
164-
* @dataProvider decoratedPropertyMetadataProvider
164+
* @dataProvider typedPropertyMetadataProvider
165165
*/
166166
public function testCreateWithTypedParentPropertyMetadataFactoryYaml(PropertyMetadata $expectedPropertyMetadata)
167167
{

tests/Metadata/Property/Factory/FileConfigurationMetadataFactoryProvider.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,32 @@ public function propertyMetadataProvider()
3838
'bar' => [['Bar'], 'baz' => 'Baz'],
3939
'baz' => 'Baz',
4040
],
41-
'subresource' => new SubresourceMetadata('Foo', true),
41+
'subresource' => new SubresourceMetadata('Foo', true, 1),
4242
];
4343

4444
return [[$this->getPropertyMetadata($metadata)]];
4545
}
4646

4747
public function decoratedPropertyMetadataProvider()
4848
{
49+
$metadata = [
50+
'description' => 'The dummy foo',
51+
'readable' => true,
52+
'writable' => true,
53+
'readableLink' => true,
54+
'writableLink' => false,
55+
'required' => true,
56+
'identifier' => false,
57+
'attributes' => ['Foo'],
58+
'subresource' => new SubresourceMetadata('Foo', true, 1),
59+
];
60+
61+
return [[$this->getPropertyMetadata($metadata)]];
62+
}
63+
64+
public function typedPropertyMetadataProvider()
65+
{
66+
// for Type we can't configure maxDepth, maxDepth is always null
4967
$metadata = [
5068
'description' => 'The dummy foo',
5169
'readable' => true,

0 commit comments

Comments
 (0)