diff options
| author | Jan-Hendrik Willms <tleilax+github@gmail.com> | 2023-12-07 14:04:18 +0100 |
|---|---|---|
| committer | Jan-Hendrik Willms <tleilax+studip@gmail.com> | 2024-10-30 12:40:05 +0000 |
| commit | 288f22cd7f789e6408c4fc8dcfac19627d0ff01b (patch) | |
| tree | f38fd112175dd78dd3833036e97b4f7e42ff6f85 /lib/classes/JsonApi/ResourceCategorySchema.php | |
| parent | 363c78feaae65f3dfaba40b39463e2f1156048d4 (diff) | |
initial commit, re #2799tic-2799
Diffstat (limited to 'lib/classes/JsonApi/ResourceCategorySchema.php')
| -rw-r--r-- | lib/classes/JsonApi/ResourceCategorySchema.php | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/lib/classes/JsonApi/ResourceCategorySchema.php b/lib/classes/JsonApi/ResourceCategorySchema.php new file mode 100644 index 0000000..3e9b995 --- /dev/null +++ b/lib/classes/JsonApi/ResourceCategorySchema.php @@ -0,0 +1,48 @@ +<?php +namespace JsonApi\Schemas; + +use Neomerx\JsonApi\Contracts\Schema\ContextInterface; +use ResourceCategory; + +final class ResourceCategorySchema extends SchemaProvider +{ + const TYPE = 'resource_categories'; + + /** + * @param ResourceCategory $resource + */ + public function getId($resource): ?string + { + return $resource->id; + } + + /** + * @param ResourceCategory $resource + */ + public function getAttributes($resource, ContextInterface $context): iterable + { + return [ + 'name' => (string) $resource->name, + 'description' => (string) $resource->description, + 'system' => (bool) $resource->system, + 'class_name' => (string) $resource->class_name, + + 'mkdate' => date('c', $resource->mkdate), + 'chdate' => date('c', $resource->chdate), + ]; + } + + /** + * @param ResourceCategory $resource + */ + public function getRelationships($resource, ContextInterface $context): iterable + { + if ($context->getPosition()->getLevel() > 0) { + return []; + }; + + $relationships = []; + + return $relationships; + } +} |
