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
14
class
ActionStartAllServices
15
{
19
private
$splash
;
20
24
private
$processed
=
false
;
25
29
const
GAUGE_PER_SERVICE
= 1;
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(
47
$bearsamppLang
->getValue(
Lang::MENU_START_SERVICES
),
48
self::GAUGE_PER_SERVICE * $enabledServicesCount + 1,
49
$bearsamppLang
->getValue(
Lang::LOADING_START_SERVICES
)
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
}
$bearsamppBins
global $bearsamppBins
Definition
ajax.apache.php:16
$bearsamppLang
global $bearsamppLang
Definition
ajax.apache.php:16
exit
exit
Definition
ajax.apply.moduleconfig.php:63
$bearsamppCore
global $bearsamppCore
Definition
ajax.latestversion.php:24
ActionStartAllServices
Definition
class.action.startAllServices.php:15
ActionStartAllServices\__construct
__construct($args)
Definition
class.action.startAllServices.php:37
ActionStartAllServices\$splash
$splash
Definition
class.action.startAllServices.php:19
ActionStartAllServices\$processed
$processed
Definition
class.action.startAllServices.php:24
ActionStartAllServices\processWindow
processWindow($window, $id, $ctrl, $param1, $param2)
Definition
class.action.startAllServices.php:68
ActionStartAllServices\GAUGE_PER_SERVICE
const GAUGE_PER_SERVICE
Definition
class.action.startAllServices.php:29
Lang\LOADING_COMPLETE
const LOADING_COMPLETE
Definition
class.lang.php:264
Lang\LOADING_START_SERVICES
const LOADING_START_SERVICES
Definition
class.lang.php:259
Lang\LOADING_START_SERVICE
const LOADING_START_SERVICE
Definition
class.lang.php:260
Lang\MENU_START_SERVICES
const MENU_START_SERVICES
Definition
class.lang.php:116
ServiceHelper\getServiceDisplayName
static getServiceDisplayName($bin, $service)
Definition
class.serviceHelper.php:95
ServiceHelper\startService
static startService($bin, $syntaxCheckCmd=null, $showErrors=true)
Definition
class.serviceHelper.php:129
ServiceHelper\processServices
static processServices($bearsamppBins, callable $callback)
Definition
class.serviceHelper.php:107
Splash
Definition
class.splash.php:17
Bearsampp-development
sandbox
core
classes
actions
class.action.startAllServices.php
Generated by
1.16.1