Skip to content

Commit 9ddeb26

Browse files
fix (jsonschema): Chain schema factory decorators
1 parent 005b443 commit 9ddeb26

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' => [
@@ -142,4 +142,11 @@ public function buildSchema(string $className, string $format = 'jsonhal', strin
142142
public function addDistinctFormat(string $format): void
143143
{
144144
}
145+
146+
public function setSchemaFactory(SchemaFactoryInterface $schemaFactory): void
147+
{
148+
if ($this->schemaFactory instanceof SchemaFactoryAwareInterface) {
149+
$this->schemaFactory->setSchemaFactory($schemaFactory);
150+
}
151+
}
145152
}

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,
@@ -185,4 +185,11 @@ public function buildSchema(string $className, string $format = 'jsonld', string
185185
public function addDistinctFormat(string $format): void
186186
{
187187
}
188+
189+
public function setSchemaFactory(SchemaFactoryInterface $schemaFactory): void
190+
{
191+
if ($this->schemaFactory instanceof SchemaFactoryAwareInterface) {
192+
$this->schemaFactory->setSchemaFactory($schemaFactory);
193+
}
194+
}
188195
}

0 commit comments

Comments
 (0)