Skip to content
Snippets Groups Projects
Commit b8356748 authored by Elmar Ludwig's avatar Elmar Ludwig
Browse files

add workaround for API change in BlockType, fixes #250

parent 99855b2a
No related branches found
No related tags found
No related merge requests found
...@@ -12,8 +12,29 @@ ...@@ -12,8 +12,29 @@
use Courseware\BlockTypes\BlockType; use Courseware\BlockTypes\BlockType;
use Opis\JsonSchema\Schema; use Opis\JsonSchema\Schema;
// use old API with Stud.IP < 6.0
if (class_exists('Opis\JsonSchema\Schema')) {
trait VipsJsonSchema
{
public static function getJsonSchema(): Schema
{
return Schema::fromJsonString(self::_getJsonSchema());
}
}
} else {
trait VipsJsonSchema
{
public static function getJsonSchema(): string
{
return self::_getJsonSchema();
}
}
}
class TestBlock extends BlockType class TestBlock extends BlockType
{ {
use VipsJsonSchema;
/** /**
* Get a short string describing this type of block. * Get a short string describing this type of block.
*/ */
...@@ -49,7 +70,7 @@ class TestBlock extends BlockType ...@@ -49,7 +70,7 @@ class TestBlock extends BlockType
/** /**
* Get the JSON schema for the payload of this block type. * Get the JSON schema for the payload of this block type.
*/ */
public static function getJsonSchema(): Schema public static function _getJsonSchema(): string
{ {
$schema = [ $schema = [
'type' => 'object', 'type' => 'object',
...@@ -60,7 +81,7 @@ class TestBlock extends BlockType ...@@ -60,7 +81,7 @@ class TestBlock extends BlockType
] ]
]; ];
return Schema::fromJsonString(json_encode($schema)); return json_encode($schema);
} }
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment