Passed
Push — master ( 262b3f...86674d )
by Yannick
09:44
created

OnlyofficeActionObserver::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 5
rs 10
c 1
b 0
f 0
1
<?php
2
/**
3
 * (c) Copyright Ascensio System SIA 2025.
4
 *
5
 * Licensed under the Apache License, Version 2.0 (the "License");
6
 * you may not use this file except in compliance with the License.
7
 * You may obtain a copy of the License at
8
 *
9
 *     http://www.apache.org/licenses/LICENSE-2.0
10
 *
11
 * Unless required by applicable law or agreed to in writing, software
12
 * distributed under the License is distributed on an "AS IS" BASIS,
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
 * See the License for the specific language governing permissions and
15
 * limitations under the License.
16
 */
17
class OnlyofficeActionObserver extends HookObserver implements HookDocumentActionObserverInterface
18
{
19
    /**
20
     * Constructor.
21
     */
22
    public function __construct()
23
    {
24
        parent::__construct(
25
            'plugin/onlyoffice/lib/onlyofficePlugin.php',
26
            'onlyoffice'
27
        );
28
    }
29
30
    /**
31
     * Create a Onlyoffice edit tools when the Chamilo loads document tools.
32
     *
33
     * @param HookDocumentActionEventInterface $event - the hook event
34
     */
35
    public function notifyDocumentAction(HookDocumentActionEventInterface $event)
36
    {
37
        $data = $event->getEventData();
38
39
        if (HOOK_EVENT_TYPE_PRE === $data['type']) {
40
            $data['actions'][] = OnlyofficeTools::getButtonCreateNew();
41
42
            return $data;
43
        }
44
    }
45
}
46