Skip to content

Commit cf0f4b1

Browse files
fix (jsonschema): Chain schema factory decorators
1 parent 704a827 commit cf0f4b1

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/Hal/JsonSchema/SchemaFactory.php

+8-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
* @author Kévin Dunglas <[email protected]>
2525
* @author Jachim Coudenys <[email protected]>
2626
*/
27-
final class SchemaFactory implements SchemaFactoryInterface
27+
final class SchemaFactory implements SchemaFactoryInterface, SchemaFactoryAwareInterface
2828
{
2929
private const HREF_PROP = [
3030
'href' => [
@@ -132,4 +132,11 @@ public function buildSchema(string $className, string $format = 'jsonhal', strin
132132

133133
return $schema;
134134
}
135+
136+
public function setSchemaFactory(SchemaFactoryInterface $schemaFactory): void
137+
{
138+
if ($this->schemaFactory instanceof SchemaFactoryAwareInterface) {
139+
$this->schemaFactory->setSchemaFactory($schemaFactory);
140+
}
141+
}
135142
}

src/Hydra/JsonSchema/SchemaFactory.php

+8-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
*
2525
* @author Kévin Dunglas <[email protected]>
2626
*/
27-
final class SchemaFactory implements SchemaFactoryInterface
27+
final class SchemaFactory implements SchemaFactoryInterface, SchemaFactoryAwareInterface
2828
{
2929
private const BASE_PROP = [
3030
'readOnly' => true,
@@ -181,4 +181,11 @@ public function buildSchema(string $className, string $format = 'jsonld', string
181181

182182
return $schema;
183183
}
184+
185+
public function setSchemaFactory(SchemaFactoryInterface $schemaFactory): void
186+
{
187+
if ($this->schemaFactory instanceof SchemaFactoryAwareInterface) {
188+
$this->schemaFactory->setSchemaFactory($schemaFactory);
189+
}
190+
}
184191
}

0 commit comments

Comments
 (0)