aboutsummaryrefslogtreecommitdiff
path: root/lib/classes/JsonApi/Schemas
diff options
context:
space:
mode:
authortgloeggl <tgloeggl@uos.de>2022-01-13 14:38:39 +0100
committertgloeggl <tgloeggl@uos.de>2022-07-28 13:59:21 +0200
commitda3db0c846bd2c3498a487727ddb11b37324824f (patch)
tree4b0b13adb6a1f55716372b75887e139d7f94df85 /lib/classes/JsonApi/Schemas
parent7d087fcdf3218f8101e592b78f948479b3d02fe2 (diff)
working on creating plugin-api for im- and exportticket-334
fix bug fix passing of custom file to block fix custom-file creation on client side working on crud custom file api for courseware blocks create correct link for custom file add read part of CRUD add delete part of CRUD change behaviour of add a new file, contents are passed via separate route update custom-file content add route to patch metadata of custom-file changes to export for reference fix jsonapi for custom-files export custom-files correctly import custom files remove custom files from file-refs revert changes to block remove obsolte use statement in Block revert changes to BlockType and Download-Block remove obsolete implements from DownloadBlock add doku, fix exporting of blocks without custom-files remove debugging messages and now obsolete code cleaning up rework custom file check fix error and remove call to mime-type for custom files rename interface methods do not assign variables in function calls
Diffstat (limited to 'lib/classes/JsonApi/Schemas')
-rwxr-xr-xlib/classes/JsonApi/Schemas/Courseware/CustomFile.php61
1 files changed, 61 insertions, 0 deletions
diff --git a/lib/classes/JsonApi/Schemas/Courseware/CustomFile.php b/lib/classes/JsonApi/Schemas/Courseware/CustomFile.php
new file mode 100755
index 0000000..21105bc
--- /dev/null
+++ b/lib/classes/JsonApi/Schemas/Courseware/CustomFile.php
@@ -0,0 +1,61 @@
+<?php
+
+namespace JsonApi\Schemas\Courseware;
+
+use JsonApi\Schemas\SchemaProvider;
+use Neomerx\JsonApi\Contracts\Schema\ContextInterface;
+use Neomerx\JsonApi\Schema\Link;
+use Neomerx\JsonApi\Contracts\Schema\LinkInterface;
+
+class CustomFile extends SchemaProvider
+{
+ const TYPE = 'courseware-custom-file';
+ //const REL_CUSTOM_FILE = 'courseware-custom-file';
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getId($resource): ?string
+ {
+ return $resource->getPayload()['id'];
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getAttributes($resource, ContextInterface $context): iterable
+ {
+ return $resource->getPayload();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getRelationships($resource, ContextInterface $context): iterable
+ {
+
+ return [];
+ }
+
+ public function getSelfLink($resource): LinkInterface
+ {
+ $link = new Link(true, '/courseware-blocks/' . $resource->getBlockId()
+ .'/custom-files', false);
+ return $link;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function hasResourceMeta($resource): bool
+ {
+ return true;
+ }
+
+ public function getResourceMeta($resource)
+ {
+ return [
+ 'download-url' => $resource->getDownloadUrl()
+ ];
+ }
+}