-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathEvents.php
More file actions
60 lines (50 loc) · 1.69 KB
/
Events.php
File metadata and controls
60 lines (50 loc) · 1.69 KB
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
<?php
namespace humhub\modules\translation;
use humhub\helpers\ControllerHelper;
use humhub\modules\space\widgets\Menu as SpaceMenu;
use humhub\modules\translation\helpers\Url;
use humhub\modules\translation\models\Languages;
use humhub\modules\ui\menu\MenuLink;
use humhub\modules\translation\commands\TranslationController;
use humhub\widgets\TopMenu;
use Yii;
class Events
{
public static function onTopMenuInit($event)
{
if (Yii::$app->user->isGuest) {
return;
}
/* @var TopMenu $menu */
$menu = $event->sender;
$menu->addEntry(new MenuLink([
'id' => 'translation-main',
'icon' => 'align-left',
'label' => Yii::t('TranslationModule.base', 'Translations'),
'url' => ['/translation/translate'],
'sortOrder' => 700,
'isActive' => ControllerHelper::isActivePath('translation', 'translate'),
]));
}
public static function onSpaceMenuInit($event)
{
$space = $event->sender->space;
if (!Languages::getLanguageBySpaceName($space)) {
return;
}
/* @var SpaceMenu $menu */
$menu = $event->sender;
$menu->addEntry(new MenuLink([
'id' => 'translation-space',
'icon' => 'align-left',
'label' => Yii::t('TranslationModule.base', 'Translations'),
'url' => Url::toStream($space),
'sortOrder' => 700,
'isActive' => ControllerHelper::isActivePath('translation', 'stream'),
]));
}
public static function onConsoleApplicationInit($event)
{
$event->sender->controllerMap['translation'] = TranslationController::class;
}
}