Skip to content

Commit 3f57765

Browse files
SchemaFactoryAwareInterface
1 parent 04410af commit 3f57765

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
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' => [
@@ -133,4 +133,11 @@ public function addDistinctFormat(string $format): void
133133
$this->schemaFactory->addDistinctFormat($format);
134134
}
135135
}
136+
137+
public function setSchemaFactory(SchemaFactoryInterface $schemaFactory): void
138+
{
139+
if ($this->schemaFactory instanceof SchemaFactoryAwareInterface) {
140+
$this->schemaFactory->setSchemaFactory($schemaFactory);
141+
}
142+
}
136143
}

src/Hydra/JsonSchema/SchemaFactory.php

+8-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
*
2626
* @author Kévin Dunglas <[email protected]>
2727
*/
28-
final class SchemaFactory implements SchemaFactoryInterface
28+
final class SchemaFactory implements SchemaFactoryInterface, SchemaFactoryAwareInterface
2929
{
3030
private const BASE_PROP = [
3131
'readOnly' => true,
@@ -190,4 +190,11 @@ public function addDistinctFormat(string $format): void
190190
$this->schemaFactory->addDistinctFormat($format);
191191
}
192192
}
193+
194+
public function setSchemaFactory(SchemaFactoryInterface $schemaFactory): void
195+
{
196+
if ($this->schemaFactory instanceof SchemaFactoryAwareInterface) {
197+
$this->schemaFactory->setSchemaFactory($schemaFactory);
198+
}
199+
}
193200
}

src/JsonApi/JsonSchema/SchemaFactory.php

+8-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
use ApiPlatform\JsonSchema\SchemaFactoryInterface;
1010
use ApiPlatform\Metadata\Operation;
1111

12-
final class SchemaFactory implements SchemaFactoryInterface
12+
final class SchemaFactory implements SchemaFactoryInterface, SchemaFactoryAwareInterface
1313
{
1414
public function __construct(private SchemaFactoryInterface $schemaFactory)
1515
{
@@ -38,4 +38,11 @@ public function addDistinctFormat(string $format): void
3838
$this->schemaFactory->addDistinctFormat($format);
3939
}
4040
}
41+
42+
public function setSchemaFactory(SchemaFactoryInterface $schemaFactory): void
43+
{
44+
if ($this->schemaFactory instanceof SchemaFactoryAwareInterface) {
45+
$this->schemaFactory->setSchemaFactory($schemaFactory);
46+
}
47+
}
4148
}

0 commit comments

Comments
 (0)