Skip to content

Commit e3f0e4f

Browse files
fix (jsonschema): Chain schema factory decorators
1 parent 4b16ba7 commit e3f0e4f

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/Hal/JsonSchema/SchemaFactory.php

Lines changed: 8 additions & 1 deletion
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' => [
@@ -129,4 +129,11 @@ public function buildSchema(string $className, string $format = 'jsonhal', strin
129129

130130
return $schema;
131131
}
132+
133+
public function setSchemaFactory(SchemaFactoryInterface $schemaFactory): void
134+
{
135+
if ($this->schemaFactory instanceof SchemaFactoryAwareInterface) {
136+
$this->schemaFactory->setSchemaFactory($schemaFactory);
137+
}
138+
}
132139
}

src/Hydra/JsonSchema/SchemaFactory.php

Lines changed: 8 additions & 1 deletion
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)