Browse Source

started work on the "Organisation" schema

dev
Cerys Lewis 4 weeks ago
parent
commit
f4320a7089
  1. 101
      Examples/Schemas/Organisation.php
  2. 8
      src/Interfaces/SchemaDocumentInterface.php

101
Examples/Schemas/Organisation.php

@ -0,0 +1,101 @@
<?phpSchemaDocumentChildField
namespace Darksparrow\AuxiliumSchemaBuilder\Examples\SchemaBuilder\Schemas;
require_once __DIR__ . "/../../vendor/autoload.php";
use Darksparrow\AuxiliumSchemaBuilder\Attributes\SchemaDocumentChildField;
use Darksparrow\AuxiliumSchemaBuilder\Enumerators\SchemaFieldExistence;
use Darksparrow\AuxiliumSchemaBuilder\Attributes\SchemaDocument;
use Darksparrow\AuxiliumSchemaBuilder\Attributes\SchemaDocumentField;
use Darksparrow\AuxiliumSchemaBuilder\Interfaces\SchemaDocumentInterface;
#[SchemaDocument(
Name: "Message",
MaxSize: 0,
Comment: "The organisation object itself SHOULD not have a value",
MimeType: "message/rfc822",
)]
class Organisation implements SchemaDocumentInterface
{
#[SchemaDocumentField(
Name: "name",
Existence: SchemaFieldExistence::MUST,
Comment: "This MUST be the organisation's name",
MaxSize: 2048,
MimeType: "test/plain",
Children: [
new SchemaDocumentField(
Name: "trading_as",
Existence: SchemaFieldExistence::SHOULD,
MaxSize: 256,
MIMEType: "text/plain",
Comment: "This SHOULD be the organisation's short trading name, or the abbreviation they would usually go by",
)
]
)]
public string $Name;
#[SchemaDocumentField(
Name: "departments",
Existence: SchemaFieldExistence::SHOULD,
Comment: "This SHOULD be an 'array node' of all sub-organisations if applicable",
ValidSchemas: [
"https://schemas.auxiliumsoftware.co.uk/v1/collection.json",
],
MaxSize: 0,
Child: new SchemaDocumentChildField(
Comment: null,
ValidSchemas: [
"https://schemas.auxiliumsoftware.co.uk/v1/organisation.json",
],
),
)]
public array $Departments;
#[SchemaDocumentField(
Name: "cases",
Existence: SchemaFieldExistence::SHOULD,
Comment: "This SHOULD be an 'array node' of all the cases the organisation is either directly working on or the client of",
ValidSchemas: [
"https://schemas.auxiliumsoftware.co.uk/v1/collection.json",
],
MaxSize: 0,
Child: new SchemaDocumentChildField(
Comment: null,
ValidSchemas: [
"https://schemas.auxiliumsoftware.co.uk/v1/case.json",
],
),
)]
public array $Cases;
#[SchemaDocumentField(
Name: "staff",
Existence: SchemaFieldExistence::SHOULD,
Comment: "This SHOULD be an 'array node' of all the staff that cannot be categorised into departments, or in the case of small organisations with no departments, all staff",
ValidSchemas: [
"https://schemas.auxiliumsoftware.co.uk/v1/collection.json",
],
MaxSize: 0,
Child: new SchemaDocumentChildField(
Comment: null,
ValidSchemas: [
"https://schemas.auxiliumsoftware.co.uk/v1/user.json",
],
),
)]
public array $Staff;
public function __construct(array $data)
{
$this->Name = $data["name"];
$this->Departments = $data["departments"];
$this->Cases = $data["cases"];
$this->Staff = $data["staff"];
}
}

8
src/Interfaces/SchemaDocumentInterface.php

@ -0,0 +1,8 @@
<?php
namespace Darksparrow\AuxiliumSchemaBuilder\Interfaces;
interface SchemaDocumentInterface
{
public function __construct(array $data);
}
Loading…
Cancel
Save