/
mikopbx
/
ModuleQualityAssessment
Обзор
Документация
Войти
/
mikopbx
/
ModuleQualityAssessment
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
master
Lib/QualityAssessmentMain.php
96 строк
3 KB
apor
Инициализация модуля.
02 авг 2023, 14:54
02 авг 2023, 14:54
4e2d114
Код
Авторство
О чём код?
<?php /* * MikoPBX - free phone system for small business * Copyright © 2017-2023 Alexey Portnov and Nikolay Beketov * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along with this program. * If not, see <https://www.gnu.org/licenses/>. */ namespace Modules\ModuleQualityAssessment\Lib; use MikoPBX\Core\System\Processes; use MikoPBX\Core\System\Util; use MikoPBX\Core\Workers\Cron\WorkerSafeScriptsCore; use MikoPBX\Modules\PbxExtensionBase; use MikoPBX\Modules\PbxExtensionUtils; use MikoPBX\PBXCoreREST\Lib\PBXApiResult; class QualityAssessmentMain extends PbxExtensionBase { /** * Process something received over AsteriskAMI * * @param array $parameters */ public function processAmiMessage(array $parameters): void { $message = implode(' ', $parameters); $this->logger->writeInfo($message); } /** * Process something received over Beanstalk queue * * @param array $parameters */ public function processBeanstalkMessage(array $parameters): void { $message = implode(' ', $parameters); $this->logger->writeInfo($message); } /** * Check something and answer over RestAPI * * @return PBXApiResult An object containing the result of the API call. */ public function checkModuleWorkProperly(): PBXApiResult { $res = new PBXApiResult(); $res->processor = __METHOD__; $res->success = true; return $res; } /** * Start or restart module workers * * @param bool $restart */ public function startAllServices(bool $restart = false): void { $moduleEnabled = PbxExtensionUtils::isEnabled($this->moduleUniqueId); if ( ! $moduleEnabled) { return; } $configClass = new QualityAssessmentConf(); $workersToRestart = $configClass->getModuleWorkers(); if ($restart) { foreach ($workersToRestart as $moduleWorker) { Processes::processPHPWorker($moduleWorker['worker']); } } else { $safeScript = new WorkerSafeScriptsCore(); foreach ($workersToRestart as $moduleWorker) { if ($moduleWorker['type'] === WorkerSafeScriptsCore::CHECK_BY_AMI) { $safeScript->checkWorkerAMI($moduleWorker['worker']); } else { $safeScript->checkWorkerBeanstalk($moduleWorker['worker']); } } } } }