-
Notifications
You must be signed in to change notification settings - Fork 1
/
CoursewareLernkartenBlockPlugin.php
76 lines (67 loc) · 2.14 KB
/
CoursewareLernkartenBlockPlugin.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
use Courseware\CoursewarePlugin;
use Lernkarten\Courseware\LernkartenBlock;
/**
* @SuppressWarnings(StaticAccess)
*/
class CoursewareLernkartenBlockPlugin extends StudIPPlugin implements SystemPlugin, CoursewarePlugin
{
public function __construct()
{
parent::__construct();
require_once __DIR__ . '/vendor/autoload.php';
if (match_route('dispatch.php/*/courseware')) {
$this->addJavascript();
$this->addStyles();
}
}
private function addJavascript(): void
{
PageLayout::addScript($this->getPluginUrl() . '/courseware/dist/lernkarten-courseware.js', [
'type' => 'module',
]);
PageLayout::addScript($this->getPluginUrl() . '/dist/register.js', [
'type' => 'module',
]);
}
private function addStyles(): void
{
// Add CSS to set the correct icon for the block in the block adder
PageLayout::addStyle(
'.cw-blockadder-item.cw-blockadder-item-lernkarten {
background-image:url(' .
Icon::create('dialog-cards')->asImagePath() .
')
}'
);
}
/**
* Implement this method to register more block types.
*
* You get the current list of block types and must return an updated list
* containing your own block types.
*
* @param array $otherBlockTypes the current list of block types
*
* @return array the updated list of block types
*/
public function registerBlockTypes(array $otherBlockTypes): array
{
$otherBlockTypes[] = LernkartenBlock::class;
return $otherBlockTypes;
}
/**
* Implement this method to register more container types.
*
* You get the current list of container types and must return an updated list
* containing your own container types.
*
* @param array $otherContainerTypes the current list of container types
*
* @return array the updated list of container types
*/
public function registerContainerTypes(array $otherContainerTypes): array
{
return $otherContainerTypes;
}
}