From b27ceacaa1ae085ecbd7e56b6e2add63631efbd0 Mon Sep 17 00:00:00 2001 From: Cerys Date: Fri, 7 Jun 2024 16:05:00 +0100 Subject: [PATCH] can roughly create a schema --- src/SchemaBuilder/Helpers/SchemaBuilder.php | 52 +++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 src/SchemaBuilder/Helpers/SchemaBuilder.php diff --git a/src/SchemaBuilder/Helpers/SchemaBuilder.php b/src/SchemaBuilder/Helpers/SchemaBuilder.php new file mode 100644 index 0000000..a1589ce --- /dev/null +++ b/src/SchemaBuilder/Helpers/SchemaBuilder.php @@ -0,0 +1,52 @@ +getProperties(); + $attributes = $reflection->getAttributes()[0]; + + $schema = []; + + /* + * Schema "meta-data" from here... + */ + foreach($attributes->getArguments() as $key=>$value) + { + if($value != "") + $schema["@$key"] = $value; + } + + /* + * Property handling from here... + */ + foreach ($properties as $property) { + $attributes = $property->getAttributes(); + $propertyName = $property->getName(); + $propertySchema = []; + + foreach ($attributes as $attribute) + { + if($attribute->getName() != "Darksparrow\DeegraphPHP\SchemaBuilder\Attributes\SchemaDocumentField") + continue; + + foreach($attribute->getArguments() as $key=>$value) + { + if($value != "") + $propertySchema["@$key"] = $value; + } + } + + $schema["$propertyName"] = $propertySchema; + } + + return $schema; + } +}