Files
XC_VM/src/Infrastructure/Bootstrap/WebApiBootstrap.php
T
Divarion-D 9eec63937e style: import/namespace hygiene across src (PHP-CS-Fixer)
Apply 'make cs-fix' — 493 files. Mechanical, import-block only:
- sort use statements alphabetically (class/function/const grouped);
- drop imports left unused by the PSR-4 migration (e.g. classes referenced by
  leading-backslash FQCN whose redundant 'use' the automated insertion had added);
- one blank line after namespace and after the import block; collapse stray
  blank lines around use.

No logic changes. Verified: php -l clean; PHPStan no errors; PHPUnit 295/295; and a
temporary PHPStan pass over src/Public/Controllers confirms no still-referenced
import was removed (0 unresolved classes). 'use' after inline HTML in view
templates is valid and aliases correctly (verified) — those imports are sorted too.
2026-06-25 20:24:36 +03:00

69 lines
2.9 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
namespace XcVm\Infrastructure\Bootstrap;
use XcVm\Core\Config\SettingsManager;
use XcVm\Core\Database\DatabaseHandler;
use XcVm\Core\Init\LegacyInitializer;
use XcVm\Core\Logging\Logger;
use XcVm\Core\Updates\GitHubReleases;
use XcVm\Infrastructure\Database\DatabaseFactory;
/**
* WebApiBootstrap — bootstrap для web API endpoint'ов
*
* @package XC_VM_Infrastructure_Bootstrap
* @author Divarion_D <https://github.com/Divarion-D>
* @copyright 2025-2026 Vateron Media
* @link https://github.com/Vateron-Media/\XC_VM
* @license AGPL-3.0 https://www.gnu.org/licenses/agpl-3.0.html
*/
class WebApiBootstrap {
/**
* Инициализирует web API контекст.
*
* @param string $rFilename Имя endpoint'а (enigma2, epg, playlist, xplugin, api, …)
*/
public static function init(string $rFilename): void {
// ── 1. Ошибки ────────────────────────────────────────────
require_once MAIN_HOME . 'Core/Error/ErrorCodes.php';
require_once MAIN_HOME . 'Core/Error/ErrorHandler.php';
// ── 2. PHP defaults ──────────────────────────────────────
@ini_set('user_agent', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36');
@ini_set('default_socket_timeout', 5);
// ── 3. Константы и конфигурация ──────────────────────────
require_once MAIN_HOME . 'Core/Config/Paths.php';
require_once MAIN_HOME . 'Core/Config/AppConfig.php';
require_once MAIN_HOME . 'Core/Config/Binaries.php';
// ── 4. Flood / host / Logger ─────────────────────────────
require_once MAIN_HOME . 'Core/Http/RequestGuard.php';
// ── 5. DB + LegacyInitializer ────────────────────────────
require_once MAIN_HOME . 'Core/Init/LegacyInitializer.php';
require_once MAIN_HOME . 'Core/Database/DatabaseHandler.php';
require_once MAIN_HOME . 'Core/Updates/GitHubReleases.php';
global $db, $gitRelease;
$rCachedEndpoints = ['enigma2', 'epg', 'playlist', 'api', 'xplugin', 'live', 'proxy_api', 'thumb', 'timeshift', 'vod'];
$rUseCache = in_array($rFilename, $rCachedEndpoints, true);
$db = new DatabaseHandler();
DatabaseFactory::set($db);
LegacyInitializer::initCore($rUseCache);
if ($rUseCache && !SettingsManager::getAll()['enable_cache']) {
$db = new DatabaseHandler();
DatabaseFactory::set($db);
}
// ── 6. GithubReleases ────────────────────────────────────
$gitRelease = new GitHubReleases(GIT_OWNER, GIT_REPO_MAIN, SettingsManager::getAll()['update_channel']);
}
}