|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/* For licensing terms, see /license.txt */ |
|
6
|
|
|
|
|
7
|
|
|
namespace Chamilo\CoreBundle\Tool; |
|
8
|
|
|
|
|
9
|
|
|
use Sylius\Bundle\SettingsBundle\Schema\SchemaInterface; |
|
10
|
|
|
use Symfony\Component\Serializer\Annotation\Groups; |
|
11
|
|
|
|
|
12
|
|
|
abstract class AbstractTool implements ToolInterface |
|
13
|
|
|
{ |
|
14
|
|
|
/** |
|
15
|
|
|
* @Groups({"ctool:read"}) |
|
16
|
|
|
*/ |
|
17
|
|
|
protected string $name; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* @Groups({"ctool:read"}) |
|
21
|
|
|
*/ |
|
22
|
|
|
protected string $icon; |
|
23
|
|
|
protected string $category; |
|
24
|
|
|
protected string $link; |
|
25
|
|
|
protected string $image; |
|
26
|
|
|
protected string $admin; |
|
27
|
|
|
protected ?SchemaInterface $settings = null; |
|
28
|
|
|
protected ?array $resourceTypes; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* @var string |
|
32
|
|
|
* |
|
33
|
|
|
* 00 disabled tool |
|
34
|
|
|
* 01 course tool |
|
35
|
|
|
* 10 global tool |
|
36
|
|
|
* 11 global or course or both |
|
37
|
|
|
*/ |
|
38
|
|
|
protected string $scope; |
|
39
|
|
|
|
|
40
|
|
|
public function __construct( |
|
41
|
|
|
string $name, |
|
42
|
|
|
string $category, |
|
43
|
|
|
string $link, |
|
44
|
|
|
?SchemaInterface $settings = null, |
|
45
|
|
|
?array $resourceTypes = [] |
|
46
|
|
|
) { |
|
47
|
|
|
$this->name = $name; |
|
48
|
|
|
$this->category = $category; |
|
49
|
|
|
$this->link = $link; |
|
50
|
|
|
$this->image = $name.'.png'; |
|
51
|
|
|
$this->settings = $settings; |
|
52
|
|
|
$this->resourceTypes = $resourceTypes; |
|
53
|
|
|
$this->icon = 'mdi-crop-square'; |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
public function isCourseTool(): bool |
|
57
|
|
|
{ |
|
58
|
|
|
return false; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
public function isGlobal(): bool |
|
62
|
|
|
{ |
|
63
|
|
|
return true; |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
public function getName(): string |
|
67
|
|
|
{ |
|
68
|
|
|
return $this->name; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
public function getLink(): string |
|
72
|
|
|
{ |
|
73
|
|
|
return $this->link ?: ''; |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
public function getCategory(): string |
|
77
|
|
|
{ |
|
78
|
|
|
return $this->category; |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
public function getTarget(): string |
|
82
|
|
|
{ |
|
83
|
|
|
return '_self'; |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
public function getImage(): string |
|
87
|
|
|
{ |
|
88
|
|
|
return $this->image; |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
public function getResourceTypes(): ?array |
|
92
|
|
|
{ |
|
93
|
|
|
return $this->resourceTypes; |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
public function setResourceTypes(?array $resourceTypes): self |
|
97
|
|
|
{ |
|
98
|
|
|
$this->resourceTypes = $resourceTypes; |
|
99
|
|
|
|
|
100
|
|
|
return $this; |
|
101
|
|
|
} |
|
102
|
|
|
|
|
103
|
|
|
public function getIcon(): string |
|
104
|
|
|
{ |
|
105
|
|
|
return $this->icon; |
|
106
|
|
|
} |
|
107
|
|
|
|
|
108
|
|
|
public function setIcon(string $icon): self |
|
109
|
|
|
{ |
|
110
|
|
|
$this->icon = $icon; |
|
111
|
|
|
|
|
112
|
|
|
return $this; |
|
113
|
|
|
} |
|
114
|
|
|
} |
|
115
|
|
|
|