diff options
| author | Jan-Hendrik Willms <tleilax+studip@gmail.com> | 2024-05-16 08:22:10 +0000 |
|---|---|---|
| committer | Jan-Hendrik Willms <tleilax+studip@gmail.com> | 2024-05-16 08:22:10 +0000 |
| commit | a8a031843d34937264f7b631e88d21401041abe8 (patch) | |
| tree | 8c2e82f0af8f8f54f8dffec5e24a97a0dfa2e781 /lib | |
| parent | 6bc8e7bb6ff1b98f90ea605fde228c5e9d69d75d (diff) | |
update opis/json-schema to 2.3.0, fixes #4173
Closes #4173
Merge request studip/studip!3011
Diffstat (limited to 'lib')
34 files changed, 71 insertions, 157 deletions
diff --git a/lib/models/Courseware/BlockTypes/Audio.php b/lib/models/Courseware/BlockTypes/Audio.php index dd2588a..22dc167 100644 --- a/lib/models/Courseware/BlockTypes/Audio.php +++ b/lib/models/Courseware/BlockTypes/Audio.php @@ -2,8 +2,6 @@ namespace Courseware\BlockTypes; -use Opis\JsonSchema\Schema; - /** * This class represents the content of a Courseware audio block. * @@ -42,11 +40,10 @@ class Audio extends BlockType ]; } - public static function getJsonSchema(): Schema + public static function getJsonSchema(): string { $schemaFile = __DIR__.'/Audio.json'; - - return Schema::fromJsonString(file_get_contents($schemaFile)); + return file_get_contents($schemaFile); } /** diff --git a/lib/models/Courseware/BlockTypes/BeforeAfter.php b/lib/models/Courseware/BlockTypes/BeforeAfter.php index b4f33ca..e174bff 100644 --- a/lib/models/Courseware/BlockTypes/BeforeAfter.php +++ b/lib/models/Courseware/BlockTypes/BeforeAfter.php @@ -2,8 +2,6 @@ namespace Courseware\BlockTypes; -use Opis\JsonSchema\Schema; - /** * This class represents the content of a Courseware before after block. * @@ -41,11 +39,10 @@ class BeforeAfter extends BlockType ]; } - public static function getJsonSchema(): Schema + public static function getJsonSchema(): string { $schemaFile = __DIR__.'/BeforeAfter.json'; - - return Schema::fromJsonString(file_get_contents($schemaFile)); + return file_get_contents($schemaFile); } /** diff --git a/lib/models/Courseware/BlockTypes/BiographyAchievements.php b/lib/models/Courseware/BlockTypes/BiographyAchievements.php index 3af5d64..2f8aeb7 100644 --- a/lib/models/Courseware/BlockTypes/BiographyAchievements.php +++ b/lib/models/Courseware/BlockTypes/BiographyAchievements.php @@ -2,8 +2,6 @@ namespace Courseware\BlockTypes; -use Opis\JsonSchema\Schema; - /** * This class represents the content of a Courseware biography achievements block. * @@ -57,11 +55,10 @@ class BiographyAchievements extends BlockType parent::setPayload($payload); } - public static function getJsonSchema(): Schema + public static function getJsonSchema(): string { $schemaFile = __DIR__.'/BiographyAchievements.json'; - - return Schema::fromJsonString(file_get_contents($schemaFile)); + return file_get_contents($schemaFile); } public static function getCategories(): array diff --git a/lib/models/Courseware/BlockTypes/BiographyCareer.php b/lib/models/Courseware/BlockTypes/BiographyCareer.php index ebd1a85..9425cfe 100644 --- a/lib/models/Courseware/BlockTypes/BiographyCareer.php +++ b/lib/models/Courseware/BlockTypes/BiographyCareer.php @@ -2,8 +2,6 @@ namespace Courseware\BlockTypes; -use Opis\JsonSchema\Schema; - /** * This class represents the content of a Courseware biography career block. * @@ -48,11 +46,11 @@ class BiographyCareer extends BlockType ]; } - public static function getJsonSchema(): Schema + public static function getJsonSchema(): string { $schemaFile = __DIR__.'/BiographyCareer.json'; - return Schema::fromJsonString(file_get_contents($schemaFile)); + return file_get_contents($schemaFile); } public static function getCategories(): array diff --git a/lib/models/Courseware/BlockTypes/BiographyGoals.php b/lib/models/Courseware/BlockTypes/BiographyGoals.php index dcfb76c..b4f1b64 100644 --- a/lib/models/Courseware/BlockTypes/BiographyGoals.php +++ b/lib/models/Courseware/BlockTypes/BiographyGoals.php @@ -2,8 +2,6 @@ namespace Courseware\BlockTypes; -use Opis\JsonSchema\Schema; - /** * This class represents the content of a Courseware biography personal goals block. * @@ -53,11 +51,11 @@ class BiographyGoals extends BlockType parent::setPayload($payload); } - public static function getJsonSchema(): Schema + public static function getJsonSchema(): string { $schemaFile = __DIR__.'/BiographyGoals.json'; - return Schema::fromJsonString(file_get_contents($schemaFile)); + return file_get_contents($schemaFile); } public static function getCategories(): array diff --git a/lib/models/Courseware/BlockTypes/BiographyPersonalInformation.php b/lib/models/Courseware/BlockTypes/BiographyPersonalInformation.php index 8f3c0c1..bb11f53 100644 --- a/lib/models/Courseware/BlockTypes/BiographyPersonalInformation.php +++ b/lib/models/Courseware/BlockTypes/BiographyPersonalInformation.php @@ -2,8 +2,6 @@ namespace Courseware\BlockTypes; -use Opis\JsonSchema\Schema; - /** * This class represents the content of a Courseware biography personal information block. * @@ -41,11 +39,11 @@ class BiographyPersonalInformation extends BlockType ]; } - public static function getJsonSchema(): Schema + public static function getJsonSchema(): string { $schemaFile = __DIR__.'/BiographyPersonalInformation.json'; - return Schema::fromJsonString(file_get_contents($schemaFile)); + return file_get_contents($schemaFile); } public static function getCategories(): array diff --git a/lib/models/Courseware/BlockTypes/BlockType.php b/lib/models/Courseware/BlockTypes/BlockType.php index b3d5abf..b87a219 100644 --- a/lib/models/Courseware/BlockTypes/BlockType.php +++ b/lib/models/Courseware/BlockTypes/BlockType.php @@ -3,7 +3,6 @@ namespace Courseware\BlockTypes; use Courseware\CoursewarePlugin; -use Opis\JsonSchema\Schema; use Opis\JsonSchema\Validator; /** @@ -52,9 +51,9 @@ abstract class BlockType * Returns the JSON schema which is used to validate the payload of * instances of this type of block. * - * @return Schema the JSON schema to be used + * @return string the JSON schema to be used */ - abstract public static function getJsonSchema(): Schema; + abstract public static function getJsonSchema(): string; /** * Returns a list of categories to which this type of block is associated. @@ -192,10 +191,8 @@ abstract class BlockType */ public function validatePayload($payload): bool { - $schema = static::getJsonSchema(); $validator = new Validator(); - $result = $validator->schemaValidation($payload, $schema); - + $result = $validator->validate($payload, static::getJsonSchema()); return $result->isValid(); } diff --git a/lib/models/Courseware/BlockTypes/Canvas.php b/lib/models/Courseware/BlockTypes/Canvas.php index e7b14e9..cc2196a 100644 --- a/lib/models/Courseware/BlockTypes/Canvas.php +++ b/lib/models/Courseware/BlockTypes/Canvas.php @@ -2,8 +2,6 @@ namespace Courseware\BlockTypes; -use Opis\JsonSchema\Schema; - /** * This class represents the content of a Courseware canvas block. * @@ -40,11 +38,11 @@ class Canvas extends BlockType ]; } - public static function getJsonSchema(): Schema + public static function getJsonSchema(): string { $schemaFile = __DIR__.'/Canvas.json'; - return Schema::fromJsonString(file_get_contents($schemaFile)); + return file_get_contents($schemaFile); } /** diff --git a/lib/models/Courseware/BlockTypes/Chart.php b/lib/models/Courseware/BlockTypes/Chart.php index 196e90f..147c3c5 100644 --- a/lib/models/Courseware/BlockTypes/Chart.php +++ b/lib/models/Courseware/BlockTypes/Chart.php @@ -2,8 +2,6 @@ namespace Courseware\BlockTypes; -use Opis\JsonSchema\Schema; - /** * This class represents the content of a Courseware chart block. * @@ -38,11 +36,11 @@ class Chart extends BlockType ]; } - public static function getJsonSchema(): Schema + public static function getJsonSchema(): string { $schemaFile = __DIR__.'/Chart.json'; - return Schema::fromJsonString(file_get_contents($schemaFile)); + return file_get_contents($schemaFile); } public static function getCategories(): array diff --git a/lib/models/Courseware/BlockTypes/Code.php b/lib/models/Courseware/BlockTypes/Code.php index 5b1454c..d5bd1c5 100644 --- a/lib/models/Courseware/BlockTypes/Code.php +++ b/lib/models/Courseware/BlockTypes/Code.php @@ -2,8 +2,6 @@ namespace Courseware\BlockTypes; -use Opis\JsonSchema\Schema; - /** * This class represents the content of a Courseware code block. * @@ -37,11 +35,11 @@ class Code extends BlockType ]; } - public static function getJsonSchema(): Schema + public static function getJsonSchema(): string { $schemaFile = __DIR__.'/Code.json'; - return Schema::fromJsonString(file_get_contents($schemaFile)); + return file_get_contents($schemaFile); } public static function getCategories(): array diff --git a/lib/models/Courseware/BlockTypes/Confirm.php b/lib/models/Courseware/BlockTypes/Confirm.php index bb6738d..2c25316 100644 --- a/lib/models/Courseware/BlockTypes/Confirm.php +++ b/lib/models/Courseware/BlockTypes/Confirm.php @@ -2,8 +2,6 @@ namespace Courseware\BlockTypes; -use Opis\JsonSchema\Schema; - /** * This class represents the content of a Courseware confirm block. * @@ -36,11 +34,11 @@ class Confirm extends BlockType ]; } - public static function getJsonSchema(): Schema + public static function getJsonSchema(): string { $schemaFile = __DIR__.'/Confirm.json'; - return Schema::fromJsonString(file_get_contents($schemaFile)); + return file_get_contents($schemaFile); } public static function getCategories(): array diff --git a/lib/models/Courseware/BlockTypes/Date.php b/lib/models/Courseware/BlockTypes/Date.php index 46e77d8..548e648 100644 --- a/lib/models/Courseware/BlockTypes/Date.php +++ b/lib/models/Courseware/BlockTypes/Date.php @@ -2,8 +2,6 @@ namespace Courseware\BlockTypes; -use Opis\JsonSchema\Schema; - /** * This class represents the content of a Courseware date block. * @@ -37,11 +35,11 @@ class Date extends BlockType ]; } - public static function getJsonSchema(): Schema + public static function getJsonSchema(): string { $schemaFile = __DIR__.'/Date.json'; - return Schema::fromJsonString(file_get_contents($schemaFile)); + return file_get_contents($schemaFile); } public static function getCategories(): array diff --git a/lib/models/Courseware/BlockTypes/DialogCards.php b/lib/models/Courseware/BlockTypes/DialogCards.php index 74b843c..875a0b3 100644 --- a/lib/models/Courseware/BlockTypes/DialogCards.php +++ b/lib/models/Courseware/BlockTypes/DialogCards.php @@ -2,8 +2,6 @@ namespace Courseware\BlockTypes; -use Opis\JsonSchema\Schema; - /** * This class represents the content of a Courseware dialog cards block. * @@ -96,11 +94,11 @@ class DialogCards extends BlockType return $payload; } - public static function getJsonSchema(): Schema + public static function getJsonSchema(): string { $schemaFile = __DIR__.'/DialogCards.json'; - return Schema::fromJsonString(file_get_contents($schemaFile)); + return file_get_contents($schemaFile); } public static function getCategories(): array diff --git a/lib/models/Courseware/BlockTypes/Document.php b/lib/models/Courseware/BlockTypes/Document.php index db1ba6e..562ec08 100644 --- a/lib/models/Courseware/BlockTypes/Document.php +++ b/lib/models/Courseware/BlockTypes/Document.php @@ -2,8 +2,6 @@ namespace Courseware\BlockTypes; -use Opis\JsonSchema\Schema; - /** * This class represents the content of a Courseware document block. * @@ -39,11 +37,10 @@ class Document extends BlockType ]; } - public static function getJsonSchema(): Schema + public static function getJsonSchema(): string { $schemaFile = __DIR__.'/Document.json'; - - return Schema::fromJsonString(file_get_contents($schemaFile)); + return file_get_contents($schemaFile); } /** diff --git a/lib/models/Courseware/BlockTypes/Download.php b/lib/models/Courseware/BlockTypes/Download.php index d736009..e7bb65c 100644 --- a/lib/models/Courseware/BlockTypes/Download.php +++ b/lib/models/Courseware/BlockTypes/Download.php @@ -2,8 +2,6 @@ namespace Courseware\BlockTypes; -use Opis\JsonSchema\Schema; - /** * This class represents the content of a Courseware download block. * @@ -72,11 +70,11 @@ class Download extends BlockType return $payload; } - public static function getJsonSchema(): Schema + public static function getJsonSchema(): string { $schemaFile = __DIR__.'/Download.json'; - return Schema::fromJsonString(file_get_contents($schemaFile)); + return file_get_contents($schemaFile); } public static function getCategories(): array diff --git a/lib/models/Courseware/BlockTypes/Embed.php b/lib/models/Courseware/BlockTypes/Embed.php index cb997ee..1b36624 100644 --- a/lib/models/Courseware/BlockTypes/Embed.php +++ b/lib/models/Courseware/BlockTypes/Embed.php @@ -2,8 +2,6 @@ namespace Courseware\BlockTypes; -use Opis\JsonSchema\Schema; - /** * This class represents the content of a Courseware embed block. * @@ -40,11 +38,10 @@ class Embed extends BlockType ]; } - public static function getJsonSchema(): Schema + public static function getJsonSchema(): string { $schemaFile = __DIR__.'/Embed.json'; - - return Schema::fromJsonString(file_get_contents($schemaFile)); + return file_get_contents($schemaFile); } public function getPayload() diff --git a/lib/models/Courseware/BlockTypes/Error.php b/lib/models/Courseware/BlockTypes/Error.php index 2e15456..3f290b1 100644 --- a/lib/models/Courseware/BlockTypes/Error.php +++ b/lib/models/Courseware/BlockTypes/Error.php @@ -2,8 +2,6 @@ namespace Courseware\BlockTypes; -use Opis\JsonSchema\Schema; - /** * This class represents the content of a Courseware error block. * @@ -34,11 +32,11 @@ class Error extends BlockType return []; } - public static function getJsonSchema(): Schema + public static function getJsonSchema(): string { $schemaFile = __DIR__.'/Error.json'; - return Schema::fromJsonString(file_get_contents($schemaFile)); + return file_get_contents($schemaFile); } public static function getCategories(): array diff --git a/lib/models/Courseware/BlockTypes/Folder.php b/lib/models/Courseware/BlockTypes/Folder.php index a3ea7d9..9f186df 100644 --- a/lib/models/Courseware/BlockTypes/Folder.php +++ b/lib/models/Courseware/BlockTypes/Folder.php @@ -2,8 +2,6 @@ namespace Courseware\BlockTypes; -use Opis\JsonSchema\Schema; - /** * This class represents the content of a Courseware folder block. * @@ -116,11 +114,10 @@ class Folder extends BlockType return $payload; } - public static function getJsonSchema(): Schema + public static function getJsonSchema(): string { $schemaFile = __DIR__.'/Folder.json'; - - return Schema::fromJsonString(file_get_contents($schemaFile)); + return file_get_contents($schemaFile); } public static function getCategories(): array diff --git a/lib/models/Courseware/BlockTypes/Gallery.php b/lib/models/Courseware/BlockTypes/Gallery.php index 5f9bb0b..5041573 100644 --- a/lib/models/Courseware/BlockTypes/Gallery.php +++ b/lib/models/Courseware/BlockTypes/Gallery.php @@ -2,8 +2,6 @@ namespace Courseware\BlockTypes; -use Opis\JsonSchema\Schema; - /** * This class represents the content of a Courseware gallery block. * @@ -133,11 +131,11 @@ class Gallery extends BlockType return $payload; } - public static function getJsonSchema(): Schema + public static function getJsonSchema(): string { $schemaFile = __DIR__.'/Gallery.json'; - return Schema::fromJsonString(file_get_contents($schemaFile)); + return file_get_contents($schemaFile); } public static function getCategories(): array diff --git a/lib/models/Courseware/BlockTypes/Headline.php b/lib/models/Courseware/BlockTypes/Headline.php index 0c82138..616af88 100644 --- a/lib/models/Courseware/BlockTypes/Headline.php +++ b/lib/models/Courseware/BlockTypes/Headline.php @@ -2,7 +2,6 @@ namespace Courseware\BlockTypes; -use Opis\JsonSchema\Schema; use Opis\JsonSchema\Validator; /** @@ -49,11 +48,10 @@ class Headline extends BlockType ]; } - public static function getJsonSchema(): Schema + public static function getJsonSchema(): string { $schemaFile = __DIR__.'/Headline.json'; - - return Schema::fromJsonString(file_get_contents($schemaFile)); + return file_get_contents($schemaFile); } /** @@ -88,11 +86,8 @@ class Headline extends BlockType public function validatePayload($payload): bool { unset($payload->background_image); - $schema = static::getJsonSchema(); - $validator = new Validator(); - $result = $validator->schemaValidation($payload, $schema); - return $result->isValid(); + return parent::validatePayload($payload); } public static function getCategories(): array diff --git a/lib/models/Courseware/BlockTypes/IFrame.php b/lib/models/Courseware/BlockTypes/IFrame.php index 5c914f9..f697e74 100644 --- a/lib/models/Courseware/BlockTypes/IFrame.php +++ b/lib/models/Courseware/BlockTypes/IFrame.php @@ -2,8 +2,6 @@ namespace Courseware\BlockTypes; -use Opis\JsonSchema\Schema; - /** * This class represents the content of a Courseware iFrame block. * @@ -45,11 +43,10 @@ class IFrame extends BlockType ]; } - public static function getJsonSchema(): Schema + public static function getJsonSchema(): string { $schemaFile = __DIR__.'/IFrame.json'; - - return Schema::fromJsonString(file_get_contents($schemaFile)); + return file_get_contents($schemaFile); } public static function getCategories(): array diff --git a/lib/models/Courseware/BlockTypes/ImageMap.php b/lib/models/Courseware/BlockTypes/ImageMap.php index e275c46..d9ad845 100644 --- a/lib/models/Courseware/BlockTypes/ImageMap.php +++ b/lib/models/Courseware/BlockTypes/ImageMap.php @@ -2,8 +2,6 @@ namespace Courseware\BlockTypes; -use Opis\JsonSchema\Schema; - /** * This class represents the content of a Courseware image map block. * @@ -66,11 +64,11 @@ class ImageMap extends BlockType return $payload; } - public static function getJsonSchema(): Schema + public static function getJsonSchema(): string { $schemaFile = __DIR__.'/ImageMap.json'; - return Schema::fromJsonString(file_get_contents($schemaFile)); + return file_get_contents($schemaFile); } public static function getCategories(): array diff --git a/lib/models/Courseware/BlockTypes/KeyPoint.php b/lib/models/Courseware/BlockTypes/KeyPoint.php index 8599704..d1e6c34 100644 --- a/lib/models/Courseware/BlockTypes/KeyPoint.php +++ b/lib/models/Courseware/BlockTypes/KeyPoint.php @@ -2,8 +2,6 @@ namespace Courseware\BlockTypes; -use Opis\JsonSchema\Schema; - /** * This class represents the content of a Courseware key point block. * @@ -38,11 +36,11 @@ class KeyPoint extends BlockType ]; } - public static function getJsonSchema(): Schema + public static function getJsonSchema(): string { $schemaFile = __DIR__.'/KeyPoint.json'; - return Schema::fromJsonString(file_get_contents($schemaFile)); + return file_get_contents($schemaFile); } public static function getCategories(): array diff --git a/lib/models/Courseware/BlockTypes/Link.php b/lib/models/Courseware/BlockTypes/Link.php index ccf9f66..3282e2c 100644 --- a/lib/models/Courseware/BlockTypes/Link.php +++ b/lib/models/Courseware/BlockTypes/Link.php @@ -2,8 +2,6 @@ namespace Courseware\BlockTypes; -use Opis\JsonSchema\Schema; - /** * This class represents the content of a Courseware link block. * @@ -39,11 +37,10 @@ class Link extends BlockType ]; } - public static function getJsonSchema(): Schema + public static function getJsonSchema(): string { $schemaFile = __DIR__.'/Link.json'; - - return Schema::fromJsonString(file_get_contents($schemaFile)); + return file_get_contents($schemaFile); } public static function getCategories(): array diff --git a/lib/models/Courseware/BlockTypes/Lti.php b/lib/models/Courseware/BlockTypes/Lti.php index 8b527c1..193bfb5 100644 --- a/lib/models/Courseware/BlockTypes/Lti.php +++ b/lib/models/Courseware/BlockTypes/Lti.php @@ -2,8 +2,6 @@ namespace Courseware\BlockTypes; -use Opis\JsonSchema\Schema; - /** * This class represents the content of a Courseware LTI block. * @@ -44,11 +42,10 @@ class Lti extends BlockType ]; } - public static function getJsonSchema(): Schema + public static function getJsonSchema(): string { $schemaFile = __DIR__.'/Lti.json'; - - return Schema::fromJsonString(file_get_contents($schemaFile)); + return file_get_contents($schemaFile); } public function getPayload() diff --git a/lib/models/Courseware/BlockTypes/TableOfContents.php b/lib/models/Courseware/BlockTypes/TableOfContents.php index c48b683..f0485b9 100644 --- a/lib/models/Courseware/BlockTypes/TableOfContents.php +++ b/lib/models/Courseware/BlockTypes/TableOfContents.php @@ -2,8 +2,6 @@ namespace Courseware\BlockTypes; -use Opis\JsonSchema\Schema; - /** * This class represents the content of a Courseware table of contents block. * @@ -37,11 +35,11 @@ class TableOfContents extends BlockType ]; } - public static function getJsonSchema(): Schema + public static function getJsonSchema(): string { $schemaFile = __DIR__.'/TableOfContents.json'; - return Schema::fromJsonString(file_get_contents($schemaFile)); + return file_get_contents($schemaFile); } public static function getCategories(): array diff --git a/lib/models/Courseware/BlockTypes/Text.php b/lib/models/Courseware/BlockTypes/Text.php index b728019..917efb3 100644 --- a/lib/models/Courseware/BlockTypes/Text.php +++ b/lib/models/Courseware/BlockTypes/Text.php @@ -2,7 +2,6 @@ namespace Courseware\BlockTypes; -use Opis\JsonSchema\Schema; require_once 'lib/classes/Markup.class.php'; /** @@ -66,11 +65,10 @@ class Text extends BlockType parent::setPayload($payload); } - public static function getJsonSchema(): Schema + public static function getJsonSchema(): string { $schemaFile = __DIR__.'/Text.json'; - - return Schema::fromJsonString(file_get_contents($schemaFile)); + return file_get_contents($schemaFile); } /** diff --git a/lib/models/Courseware/BlockTypes/Timeline.php b/lib/models/Courseware/BlockTypes/Timeline.php index 81802ce..5647e92 100644 --- a/lib/models/Courseware/BlockTypes/Timeline.php +++ b/lib/models/Courseware/BlockTypes/Timeline.php @@ -2,8 +2,6 @@ namespace Courseware\BlockTypes; -use Opis\JsonSchema\Schema; - /** * This class represents the content of a Courseware timeline block. * @@ -45,11 +43,10 @@ class Timeline extends BlockType ]; } - public static function getJsonSchema(): Schema + public static function getJsonSchema(): string { $schemaFile = __DIR__.'/Timeline.json'; - - return Schema::fromJsonString(file_get_contents($schemaFile)); + return file_get_contents($schemaFile); } public static function getCategories(): array diff --git a/lib/models/Courseware/BlockTypes/Typewriter.php b/lib/models/Courseware/BlockTypes/Typewriter.php index 2544dde..b303fb3 100644 --- a/lib/models/Courseware/BlockTypes/Typewriter.php +++ b/lib/models/Courseware/BlockTypes/Typewriter.php @@ -2,8 +2,6 @@ namespace Courseware\BlockTypes; -use Opis\JsonSchema\Schema; - /** * This class represents the content of a Courseware typewriter block. * @@ -39,11 +37,11 @@ class Typewriter extends BlockType ]; } - public static function getJsonSchema(): Schema + public static function getJsonSchema(): string { $schemaFile = __DIR__.'/Typewriter.json'; - return Schema::fromJsonString(file_get_contents($schemaFile)); + return file_get_contents($schemaFile); } public static function getCategories(): array diff --git a/lib/models/Courseware/BlockTypes/Video.php b/lib/models/Courseware/BlockTypes/Video.php index 431f69b..1ad7064 100644 --- a/lib/models/Courseware/BlockTypes/Video.php +++ b/lib/models/Courseware/BlockTypes/Video.php @@ -2,8 +2,6 @@ namespace Courseware\BlockTypes; -use Opis\JsonSchema\Schema; - /** * This class represents the content of a Courseware video block. * @@ -42,11 +40,10 @@ class Video extends BlockType ]; } - public static function getJsonSchema(): Schema + public static function getJsonSchema(): string { $schemaFile = __DIR__.'/Video.json'; - - return Schema::fromJsonString(file_get_contents($schemaFile)); + return file_get_contents($schemaFile); } /** diff --git a/lib/models/Courseware/ContainerTypes/AccordionContainer.php b/lib/models/Courseware/ContainerTypes/AccordionContainer.php index 185b6d1..cd00a06 100644 --- a/lib/models/Courseware/ContainerTypes/AccordionContainer.php +++ b/lib/models/Courseware/ContainerTypes/AccordionContainer.php @@ -2,8 +2,6 @@ namespace Courseware\ContainerTypes; -use Opis\JsonSchema\Schema; - /** * This class represents the content of a Courseware accordion container stored in payload. * @@ -54,10 +52,10 @@ class AccordionContainer extends ContainerType $this->setPayload($payload); } - public static function getJsonSchema(): Schema + public static function getJsonSchema(): string { $schemaFile = __DIR__.'/AccordionContainer.json'; - return Schema::fromJsonString(file_get_contents($schemaFile)); + return file_get_contents($schemaFile); } } diff --git a/lib/models/Courseware/ContainerTypes/ContainerType.php b/lib/models/Courseware/ContainerTypes/ContainerType.php index a4eae29..baddaab 100644 --- a/lib/models/Courseware/ContainerTypes/ContainerType.php +++ b/lib/models/Courseware/ContainerTypes/ContainerType.php @@ -3,7 +3,6 @@ namespace Courseware\ContainerTypes; use Courseware\CoursewarePlugin; -use Opis\JsonSchema\Schema; use Opis\JsonSchema\Validator; /** @@ -28,9 +27,9 @@ abstract class ContainerType * Returns the JSON schema which is used to validate the payload of * instances of this type of container. * - * @return Schema the JSON schema to be used + * @return string the JSON schema to be used */ - abstract public static function getJsonSchema(): Schema; + abstract public static function getJsonSchema(): string; /** * Returns a short string describing this type of container. @@ -150,10 +149,8 @@ abstract class ContainerType */ public function validatePayload($payload): bool { - $schema = static::getJsonSchema(); $validator = new Validator(); - $result = $validator->schemaValidation($payload, $schema); - + $result = $validator->validate($payload, static::getJsonSchema()); return $result->isValid(); } diff --git a/lib/models/Courseware/ContainerTypes/ListContainer.php b/lib/models/Courseware/ContainerTypes/ListContainer.php index b98d8a1..adbf7c3 100644 --- a/lib/models/Courseware/ContainerTypes/ListContainer.php +++ b/lib/models/Courseware/ContainerTypes/ListContainer.php @@ -2,8 +2,6 @@ namespace Courseware\ContainerTypes; -use Opis\JsonSchema\Schema; - /** * This class represents the content of a Courseware list container stored in payload. * @@ -50,10 +48,9 @@ class ListContainer extends ContainerType $this->setPayload($payload); } - public static function getJsonSchema(): Schema + public static function getJsonSchema(): string { $schemaFile = __DIR__.'/ListContainer.json'; - - return Schema::fromJsonString(file_get_contents($schemaFile)); + return file_get_contents($schemaFile); } } diff --git a/lib/models/Courseware/ContainerTypes/TabsContainer.php b/lib/models/Courseware/ContainerTypes/TabsContainer.php index 01f3d45..66a56b8 100644 --- a/lib/models/Courseware/ContainerTypes/TabsContainer.php +++ b/lib/models/Courseware/ContainerTypes/TabsContainer.php @@ -2,8 +2,6 @@ namespace Courseware\ContainerTypes; -use Opis\JsonSchema\Schema; - /** * This class represents the content of a Courseware tabs container stored in payload. * @@ -54,10 +52,9 @@ class TabsContainer extends ContainerType $this->setPayload($payload); } - public static function getJsonSchema(): Schema + public static function getJsonSchema(): string { $schemaFile = __DIR__.'/TabsContainer.json'; - - return Schema::fromJsonString(file_get_contents($schemaFile)); + return file_get_contents($schemaFile); } } |
