-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathEvents.php
44 lines (34 loc) · 1.19 KB
/
Events.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
<?php
/**
* @link https://www.humhub.org/
* @copyright Copyright (c) 2021 HumHub GmbH & Co. KG
* @license https://www.humhub.com/licences
*/
namespace humhub\modules\text_editor;
use humhub\modules\file\handler\FileHandlerCollection;
use Yii;
class Events
{
public static function onFileHandlerCollection($event)
{
/* @var $collection FileHandlerCollection */
$collection = $event->sender;
/* @var $module Module */
$module = Yii::$app->getModule('text-editor');
if ($collection->type === FileHandlerCollection::TYPE_CREATE) {
if ($module->canCreate()) {
$collection->register(new filehandler\CreateFileHandler());
}
return;
}
if (!$module->isSupportedType($collection->file)) {
return;
}
if ($collection->type == FileHandlerCollection::TYPE_EDIT && $module->canEdit($collection->file)) {
$collection->register(new filehandler\EditFileHandler());
}
if ($collection->type == FileHandlerCollection::TYPE_VIEW && $module->canView($collection->file)) {
$collection->register(new filehandler\ViewFileHandler());
}
}
}