Passed
Push — develop ( c1253e...f72558 )
by Nikolay
12:51
created

PostController::callAction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
nc 1
nop 1
1
<?php
2
/*
3
 * MikoPBX - free phone system for small business
4
 * Copyright © 2017-2023 Alexey Portnov and Nikolay Beketov
5
 *
6
 * This program is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation; either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License along with this program.
17
 * If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
namespace MikoPBX\PBXCoreREST\Controllers\Modules\Core;
21
22
use MikoPBX\PBXCoreREST\Controllers\BaseController;
23
use MikoPBX\PBXCoreREST\Lib\ModulesManagementProcessor;
24
25
/**
26
 * Modules management (POST).
27
 *
28
 * @RoutePrefix("/pbxcore/api/modules/core")
29
 *
30
 * @examples
31
 *
32
 * Enables an extension module.
33
 * curl -X POST -d '{"uniqid":"ModuleSmartIVR"} http://127.0.0.1/pbxcore/api/system/enableModule
34
 *
35
 * Disables an extension module.
36
 * curl -X POST -d '{"uniqid":"ModuleSmartIVR"} http://127.0.0.1/pbxcore/api/system/disableModule
37
 *
38
 * Uninstall an extension module.
39
 * curl -X POST -d '{"uniqid":"ModuleSmartIVR"} http://127.0.0.1/pbxcore/api/system/uninstallModule
40
 *
41
 */
42
class PostController extends BaseController
43
{
44
    /**
45
     * Handles the call to different actions based on the action name
46
     *
47
     * @param string $actionName The name of the action
48
     *
49
     * Starts the module download in a separate background process.
50
     * @Post ("/moduleStartDownload")
51
     *
52
     * Returns the download status of a module.
53
     * @Post ("/moduleDownloadStatus")
54
     *
55
     * Installs a new additional extension module from an early uploaded zip archive.
56
     * @Post ("/installNewModule")
57
     *
58
     * Checks the status of a module installation by the provided zip file path.
59
     * @Post ("/statusOfModuleInstallation")
60
     *
61
     * Enables an extension module.
62
     * @Post ("/enableModule")
63
     *
64
     * Disables an extension module.
65
     * @Post ("/disableModule")
66
     *
67
     * Uninstall an extension module.
68
     * @Post ("/uninstallModule")
69
     *
70
     * @return void
71
     */
72
    public function callAction(string $actionName): void
73
    {
74
        $data = $this->request->getPost();
75
        $this->sendRequestToBackendWorker(ModulesManagementProcessor::class, $actionName, $data);
76
    }
77
78
}