diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index e4b3b5be207dde409a9b675b2f658e6652f3d302..d262513a05f14862939b5d5b3d3dd45dc890a2ec 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -29,6 +29,9 @@ - Im Rahmen von [Issue #4118](https://gitlab.studip.de/studip/studip/-/issues/4118) wurde `write_excel` ausgebaut. Als Alternative kann `phpoffice/phpspreadsheet` verwendet werden. - Im Rahmen von [TIC #3701](https://gitlab.studip.de/studip/studip/-/issues/3701) wurden die Klassen für den Cache umbenannt. Alle Vorkommnisse sollten ersetzt werden: - `StudipCacheFactory` -> `Studip\Cache\Factory` +- Die Bibliothek `opis/json-schema` wurde auf Version 2.3.0 aktualisiert ([Issue #4173](https://gitlab.studip.de/studip/studip/-/issues/4173)). Dadurch ergeben sich die folgenden Änderungen für Komponenten aus Courseware (siehe auch [Migration Guide](https://opis.io/json-schema/2.x/php-migration.html#validator)): + - Instanzen von `Courseware\ContainerTypes\BlockType` müssen die Methode `getJsonSchema` anpassen. Der Return Type ist nun `string` und es muss der Inhalt der Schema-Datei zurückgegeben werden ohne Aufruf von `Schema::fromJsonString()`. + - Instanzen von `Courseware\ContainerTypes\ContainerType` müssen die Methode `getJsonSchema` anpassen. Der Return Type ist nun `string` und es muss der Inhalt der Schema-Datei zurückgegeben werden ohne Aufruf von `Schema::fromJsonString()`. ## Security related issues diff --git a/composer.json b/composer.json index abfff34758a73f99262c32ae03dee628580a71df..ac010e5ea8d7af47636cf0cf105e1bfcbb33e256 100644 --- a/composer.json +++ b/composer.json @@ -42,7 +42,7 @@ "ext-pdo": "*", "ext-mbstring": "*", "ext-dom": "*", - "opis/json-schema": "^1.0", + "opis/json-schema": "2.3.0", "slim/psr7": "1.6.1", "slim/slim": "4.13.0", "php-di/php-di": "7.0.0", diff --git a/composer.lock b/composer.lock index f82debe1b7097015172afe1ecabcf5bb2d1e36d6..c2d073c3ce82d649c1b2df13f3ac1361e1650db5 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "e56f52fb79feb267575817504f36ad7c", + "content-hash": "ce45f97b00f8fa90b09d0b907b3a4f53", "packages": [ { "name": "algo26-matthias/idna-convert", @@ -1823,36 +1823,33 @@ }, { "name": "opis/json-schema", - "version": "1.1.0", + "version": "2.3.0", "source": { "type": "git", "url": "https://github.com/opis/json-schema.git", - "reference": "39d8072be8657a329a284339994401066406c43b" + "reference": "c48df6d7089a45f01e1c82432348f2d5976f9bfb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/opis/json-schema/zipball/39d8072be8657a329a284339994401066406c43b", - "reference": "39d8072be8657a329a284339994401066406c43b", + "url": "https://api.github.com/repos/opis/json-schema/zipball/c48df6d7089a45f01e1c82432348f2d5976f9bfb", + "reference": "c48df6d7089a45f01e1c82432348f2d5976f9bfb", "shasum": "" }, "require": { - "php": ">=7.0" + "ext-json": "*", + "opis/string": "^2.0", + "opis/uri": "^1.0", + "php": "^7.4 || ^8.0" }, "require-dev": { "ext-bcmath": "*", "ext-intl": "*", - "ext-json": "*", - "ext-mbstring": "*", - "opis/string": "^1.4", - "phpunit/phpunit": "^6.5 || ^7.0 || ^9.4" - }, - "suggest": { - "opis/string": "A standalone library for manipulating multibyte strings" + "phpunit/phpunit": "^9.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "2.x-dev" } }, "autoload": { @@ -1874,19 +1871,145 @@ "email": "marius.sarca@gmail.com" } ], - "description": "Json Schema Validator", - "homepage": "http://www.opis.io/json-schema", + "description": "Json Schema Validator for PHP", + "homepage": "https://opis.io/json-schema", "keywords": [ "json", + "json-schema", "schema", "validation", "validator" ], "support": { "issues": "https://github.com/opis/json-schema/issues", - "source": "https://github.com/opis/json-schema/tree/1.1.0" + "source": "https://github.com/opis/json-schema/tree/2.3.0" + }, + "time": "2022-01-08T20:38:03+00:00" + }, + { + "name": "opis/string", + "version": "2.0.1", + "source": { + "type": "git", + "url": "https://github.com/opis/string.git", + "reference": "9ebf1a1f873f502f6859d11210b25a4bf5d141e7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/opis/string/zipball/9ebf1a1f873f502f6859d11210b25a4bf5d141e7", + "reference": "9ebf1a1f873f502f6859d11210b25a4bf5d141e7", + "shasum": "" + }, + "require": { + "ext-iconv": "*", + "ext-json": "*", + "php": "^7.4 || ^8.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.x-dev" + } + }, + "autoload": { + "psr-4": { + "Opis\\String\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Marius Sarca", + "email": "marius.sarca@gmail.com" + }, + { + "name": "Sorin Sarca", + "email": "sarca_sorin@hotmail.com" + } + ], + "description": "Multibyte strings as objects", + "homepage": "https://opis.io/string", + "keywords": [ + "multi-byte", + "opis", + "string", + "string manipulation", + "utf-8" + ], + "support": { + "issues": "https://github.com/opis/string/issues", + "source": "https://github.com/opis/string/tree/2.0.1" + }, + "time": "2022-01-14T15:42:23+00:00" + }, + { + "name": "opis/uri", + "version": "1.1.0", + "source": { + "type": "git", + "url": "https://github.com/opis/uri.git", + "reference": "0f3ca49ab1a5e4a6681c286e0b2cc081b93a7d5a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/opis/uri/zipball/0f3ca49ab1a5e4a6681c286e0b2cc081b93a7d5a", + "reference": "0f3ca49ab1a5e4a6681c286e0b2cc081b93a7d5a", + "shasum": "" + }, + "require": { + "opis/string": "^2.0", + "php": "^7.4 || ^8.0" + }, + "require-dev": { + "phpunit/phpunit": "^9" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Opis\\Uri\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Marius Sarca", + "email": "marius.sarca@gmail.com" + }, + { + "name": "Sorin Sarca", + "email": "sarca_sorin@hotmail.com" + } + ], + "description": "Build, parse and validate URIs and URI-templates", + "homepage": "https://opis.io", + "keywords": [ + "URI Template", + "parse url", + "punycode", + "uri", + "uri components", + "url", + "validate uri" + ], + "support": { + "issues": "https://github.com/opis/uri/issues", + "source": "https://github.com/opis/uri/tree/1.1.0" }, - "time": "2021-04-14T20:02:50+00:00" + "time": "2021-05-22T15:57:08+00:00" }, { "name": "paragonie/constant_time_encoding", diff --git a/lib/models/Courseware/BlockTypes/Audio.php b/lib/models/Courseware/BlockTypes/Audio.php index dd2588a1e5ea301f8a5697591528790a2ba24435..22dc16710d36b1ddb53ce6843b765a012957de77 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 b4f33ca9c0854dbefc6eea994887f764547330c3..e174bff2d09dd3dd9a2ebf08843bbe0c0be3fc2a 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 3af5d64daee1c359be66bf121481953fd892dc3b..2f8aeb7a0003ba1134ff6e4c0a1c6e18ea5d27f2 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 ebd1a858a9792c0d61fdd83fb0549e02c09a0b1a..9425cfed40576c5ed6867c5b943c471761c7dfb4 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 dcfb76cc961b3ea2f176847586fa992bced995fa..b4f1b64429990ef2d78eef4a5a893e0b221c838a 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 8f3c0c16d4ed6ceab9ef53d2853eca285ef5f3be..bb11f530a37929db0a3bebba4f501d18c0bca82e 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 b3d5abfba7f9d93d517253a3e941672bd51f2221..b87a219fbadab02a8f05d3a18cc05df96d52c23e 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 e7b14e99665bd9ed3745aae213e7d8b41d2ff82e..cc2196accd743487dcc9889da59b64f9ec0fe614 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 196e90ff0fbfd57fb09560a436aef90fcf242a17..147c3c514591944a3a8ffa9f38a299cd9e32e1b2 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 5b1454cd82410069755b1c8d71e5d3a426ccc279..d5bd1c52b918175fe12b9c4263b33b657cf13bad 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 bb6738d5f74be216f06b2aa95ed0a37fb50bebd5..2c25316ee48f2c7eeaf39cd1598518f4720df075 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 46e77d85ea31523ad869ce8d040fb8ece9744530..548e648da23c9ffec01616e8462a414a831abe13 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 74b843cbe268886314886aa4ccae4e1514b6ad8f..875a0b3c30dce38acc1f083bce05c8e287dbdf92 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 db1ba6ee179fb0dfcc6ccc4d6808a2a155cb8eef..562ec08da2a1587567e64673d9b3779c2bd54d13 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 d736009d1815230ec4a52367b32a8ff756039adb..e7bb65c2035025c6c5b04d87ee4649cea74b8971 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 cb997ee0239e9097c333f0b7f85e6cd3556d4afd..1b3662412257f92847d1e8d1a402d11159c4e772 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 2e154562383be54bff4f40b3d01e007d4d42c6a0..3f290b1ce072e391d48c55caba96b58ab853a405 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 a3ea7d96f2016320e1a09244682c7d6c793f5841..9f186dfd092898cc7f9b85f47d36bb8766ef8be7 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 5f9bb0b6d56d3c8c8d5acc5f503f09306cef3f8d..5041573d8d3656f33548226577dca8267934d4a0 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 0c821386b82dee191489486bb10b5e2213596bc6..616af887ca383fba20c085553ec7ca540ecedbae 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 5c914f9e8fbd41515fded3b923fa12827b1aaf92..f697e742fbf9847b23d9d6563592fd32a89c1b9f 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 e275c46254ef90dd66b8e008977e41b1de9f8aa1..d9ad8454344643ad8c773c6d1c218f3093a0dc21 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 859970471a2f38c9263040d1802f45bca0116e79..d1e6c349c8c59d20ae0c91a99c2289547e407128 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 ccf9f66d36895688fbde138fd160e71b5522df99..3282e2c4bc8e414de9dd6a5769772b4216463e6c 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 8b527c193dfe4ba40dd9031f9180bdbff1459388..193bfb5722798322865450cdfa86c180594d4083 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 c48b6835443bdd61c053da7a4ff7d00dcbc450d8..f0485b9766a6352a500f14084df56cc9e76184ea 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 b72801945e69f7c8fc37a7538b25eaeb6e5991be..917efb3dfe431c8f73c9b0f02692e3aabc9c424c 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 81802cea3ea2d762fd20dc59050eb039031d0cd2..5647e92ca39fac6868912c89ddad76bc1fa7e21b 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 2544ddee1eb35d4a0d5e489c5bc8b82b910c83ce..b303fb36536c56c74a7186f0c036db9d7210cfd5 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 431f69b68e6db77e87980ee7716cfcd03bd67345..1ad70646d2e90a7b9525ec1f2f3d828a44af18a7 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 185b6d113d8b26eac1eb9dc8587ab79ac359f247..cd00a063a45839890fe94dc2549d1fd5cf50a852 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 a4eae29ba823b961f1117f6c2367ce6ee9bb2940..baddaabf5c01b99b6517187e29b146e0e6e28d0b 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 b98d8a1aaf9aa57c7cc60e54b19bba43016bf54b..adbf7c3bdd714c37f73035a2d40bc07212fcb45a 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 01f3d451043a3d79148745bfaee3a0a9a566a436..66a56b8f8846322b8626a65798ddec1f100362ec 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); } }