Bearsampp 2026.3.26
API documentation
Loading...
Searching...
No Matches
class.action.startAllServices.php
Go to the documentation of this file.
1<?php
2/*
3 * Copyright (c) 2021-2024 Bearsampp
4 * License: GNU General Public License version 3 or later; see LICENSE.txt
5 * Author: Bear
6 * Website: https://bearsampp.com
7 * Github: https://github.com/Bearsampp
8 */
9
15{
19 private $splash;
20
24 private $processed = false;
25
30
37 public function __construct($args)
38 {
39 global $bearsamppCore, $bearsamppLang, $bearsamppBins, $bearsamppWinbinder;
40
41 // Count enabled services for progress bar
42 $enabledServicesCount = count($bearsamppBins->getServices());
43
44 // Start splash screen
45 $this->splash = new Splash();
46 $this->splash->init(
48 self::GAUGE_PER_SERVICE * $enabledServicesCount + 1,
50 );
51
52 // Set handler for the splash screen window with 1000ms timeout
53 $bearsamppWinbinder->setHandler($this->splash->getWbWindow(), $this, 'processWindow', 1000);
54 $bearsamppWinbinder->mainLoop();
55 $bearsamppWinbinder->reset();
56 }
57
68 public function processWindow($window, $id, $ctrl, $param1, $param2)
69 {
70 global $bearsamppBins, $bearsamppLang, $bearsamppWinbinder;
71
72 // Only process once
73 if ($this->processed) {
74 return;
75 }
76 $this->processed = true;
77
78 // Start all services using ServiceHelper
79 ServiceHelper::processServices($bearsamppBins, function($serviceName, $service, $bin, $syntaxCheckCmd) use ($bearsamppLang) {
80 $name = ServiceHelper::getServiceDisplayName($bin, $service);
81
82 $this->splash->incrProgressBar();
83 $this->splash->setTextLoading(sprintf($bearsamppLang->getValue(Lang::LOADING_START_SERVICE), $name));
84
85 // Start the service
86 ServiceHelper::startService($bin, $syntaxCheckCmd, false);
87 });
88
89 // Final update
90 $this->splash->incrProgressBar();
91 $this->splash->setTextLoading($bearsamppLang->getValue(Lang::LOADING_COMPLETE));
92
93 // Close the splash screen and exit cleanly
94 $bearsamppWinbinder->destroyWindow($window);
95 $bearsamppWinbinder->reset();
96 exit(0);
97 }
98}
global $bearsamppBins
global $bearsamppLang
global $bearsamppCore
processWindow($window, $id, $ctrl, $param1, $param2)
const LOADING_COMPLETE
const LOADING_START_SERVICES
const LOADING_START_SERVICE
const MENU_START_SERVICES
static getServiceDisplayName($bin, $service)
static startService($bin, $syntaxCheckCmd=null, $showErrors=true)
static processServices($bearsamppBins, callable $callback)