-
Notifications
You must be signed in to change notification settings - Fork 5
/
Events.php
48 lines (37 loc) · 1.14 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
45
46
47
48
<?php
/**
* @link https://www.humhub.org/
* @copyright Copyright (c) 2017 HumHub GmbH & Co. KG
* @license https://www.humhub.com/licences
*/
namespace humhub\modules\drawio;
use Yii;
use humhub\modules\file\handler\FileHandlerCollection;
use humhub\modules\file\libs\FileHelper;
/**
* @author luke
*/
class Events
{
public static function onFileHandlerCollection($event)
{
/* @var $collection FileHandlerCollection */
$collection = $event->sender;
if ($collection->type === FileHandlerCollection::TYPE_CREATE) {
$collection->register(new filehandler\CreateFileHandler());
return;
}
/* @var $module \humhub\modules\drawio\Module */
$module = Yii::$app->getModule('drawio');
if ($collection->file === null) {
return;
}
$extension = FileHelper::getExtension($collection->file->file_name);
if (!in_array($extension, $module->getExtensions())) {
return;
}
if ($collection->type == FileHandlerCollection::TYPE_EDIT) {
$collection->register(new filehandler\EditFileHandler());
}
}
}