Compare commits

...

2 Commits

  1. 6
      Examples/ExampleScripts/generateMessageSchema.php
  2. 2
      Examples/Schemas/Message.php
  3. 8
      src/SchemaBuilder/SchemaBuilder.php

6
Examples/ExampleScripts/generateMessageSchema.php

@ -1,12 +1,12 @@
<?php <?php
namespace Darksparrow\Deegraph\examples\SchemaBuilder; namespace Darksparrow\AuxiliumSchemaBuilder\examples\SchemaBuilder;
require_once __DIR__ . "/../../vendor/autoload.php"; require_once __DIR__ . "/../../vendor/autoload.php";
require_once __DIR__ . "/../../Examples/Schemas/Message.php"; require_once __DIR__ . "/../../Examples/Schemas/Message.php";
use Darksparrow\Deegraph\Examples\SchemaBuilder\Schemas\Message; use Darksparrow\AuxiliumSchemaBuilder\Examples\SchemaBuilder\Schemas\Message;
use Darksparrow\AuxiliumSchemaBuilder\SchemaBuilder\SchemaBuilder; use Darksparrow\AuxiliumSchemaBuilder\SchemaBuilder\SchemaBuilder;
SchemaBuilder::RenderSchema(new Message()); SchemaBuilder::RenderSchema(Message::class);

2
Examples/Schemas/Message.php

@ -1,6 +1,6 @@
<?php <?php
namespace Darksparrow\Deegraph\Examples\SchemaBuilder\Schemas; namespace Darksparrow\AuxiliumSchemaBuilder\Examples\SchemaBuilder\Schemas;
require_once __DIR__ . "/../../vendor/autoload.php"; require_once __DIR__ . "/../../vendor/autoload.php";
use Darksparrow\AuxiliumSchemaBuilder\Attributes\SchemaDocumentChildField; use Darksparrow\AuxiliumSchemaBuilder\Attributes\SchemaDocumentChildField;

8
src/SchemaBuilder/SchemaBuilder.php

@ -62,11 +62,11 @@ class SchemaBuilder
/** /**
* @throws SchemaDocumentFieldNameUnsetException * @throws SchemaDocumentFieldNameUnsetException
*/ */
public static function GenerateSchema(object $targetSchema): array public static function GenerateSchema(string $targetSchemaClassName): array
{ {
$schema = []; $schema = [];
$validKeys = self::GetValidKeys(); $validKeys = self::GetValidKeys();
$reflection = new ReflectionClass($targetSchema); $reflection = new ReflectionClass(new $targetSchemaClassName());
/* /*
* Schema "meta-data" from here... * Schema "meta-data" from here...
@ -123,9 +123,9 @@ class SchemaBuilder
* @return void * @return void
* @throws SchemaDocumentFieldNameUnsetException * @throws SchemaDocumentFieldNameUnsetException
*/ */
#[NoReturn] public static function RenderSchema(object $targetSchema): void #[NoReturn] public static function RenderSchema(string $targetSchemaClassName): void
{ {
$result = self::GenerateSchema(new $targetSchema()); $result = self::GenerateSchema($targetSchemaClassName);
header('Content-Type: application/json'); header('Content-Type: application/json');
echo json_encode($result, JSON_PRETTY_PRINT); echo json_encode($result, JSON_PRETTY_PRINT);
die(); die();

Loading…
Cancel
Save