forked from humhub/translation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Events.php
47 lines (40 loc) · 1.38 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
<?php
namespace humhub\modules\translation;
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 Yii;
class Events
{
public static function onTopMenuInit($event)
{
$event->sender->addEntry(new MenuLink([
'id' => 'translation-main',
'icon' => 'align-left',
'label' => Yii::t('TranslationModule.base', 'Translations'),
'url' => ['/translation/translate'],
'sortOrder' => 700,
'isActive' => MenuLink::isActiveState('translation', 'translate')
]));
}
public static function onSpaceMenuInit($event)
{
$space = $event->sender->space;
if(!Languages::getLanguageBySpaceName($space)) {
return;
}
$event->sender->addEntry(new MenuLink([
'id' => 'translation-space',
'icon' => 'align-left',
'label' => Yii::t('TranslationModule.base', 'Translations'),
'url' => Url::toStream($space),
'sortOrder' => 700,
'isActive' => MenuLink::isActiveState('translation', 'stream')
]));
}
public static function onConsoleApplicationInit($event)
{
$event->sender->controllerMap['translation'] = TranslationController::class;
}
}