Bearsampp 2026.3.26
API documentation
Loading...
Searching...
No Matches
ActionRestartAllServices Class Reference

Public Member Functions

 __construct ($args)
 processWindow ($window, $id, $ctrl, $param1, $param2)

Data Fields

const GAUGE_PER_SERVICE = 2

Private Attributes

 $processed = false
 $splash

Detailed Description

Class ActionRestartAllServices Handles restarting all services with a single splash screen showing progress. Stops all services first, then starts them all.

Definition at line 15 of file class.action.restartAllServices.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( $args)

ActionRestartAllServices constructor. Initializes the restarting process, displays the splash screen, and sets up the main loop.

Parameters
array$argsCommand line arguments.

Definition at line 38 of file class.action.restartAllServices.php.

39 {
40 global $bearsamppCore, $bearsamppLang, $bearsamppBins, $bearsamppWinbinder;
41
42 // Count enabled services for progress bar
43 $enabledServicesCount = count($bearsamppBins->getServices());
44
45 // Start splash screen (2 operations per service: stop + start)
46 $this->splash = new Splash();
47 $this->splash->init(
49 self::GAUGE_PER_SERVICE * $enabledServicesCount + 1,
51 );
52
53 // Set handler for the splash screen window with 1000ms timeout
54 $bearsamppWinbinder->setHandler($this->splash->getWbWindow(), $this, 'processWindow', 1000);
55 $bearsamppWinbinder->mainLoop();
56 $bearsamppWinbinder->reset();
57 }
global $bearsamppBins
global $bearsamppLang
global $bearsamppCore
const MENU_RESTART_SERVICES
const LOADING_RESTART_SERVICES

References $bearsamppBins, $bearsamppCore, $bearsamppLang, Lang\LOADING_RESTART_SERVICES, and Lang\MENU_RESTART_SERVICES.

Member Function Documentation

◆ processWindow()

processWindow ( $window,
$id,
$ctrl,
$param1,
$param2 )

Processes the splash screen window events. Stops all services, then starts them all sequentially with progress updates.

Parameters
resource$windowThe window resource.
int$idThe event ID.
int$ctrlThe control ID.
mixed$param1Additional parameter 1.
mixed$param2Additional parameter 2.

Definition at line 69 of file class.action.restartAllServices.php.

70 {
71 global $bearsamppBins, $bearsamppLang, $bearsamppWinbinder;
72
73 // Only process once
74 if ($this->processed) {
75 return;
76 }
77 $this->processed = true;
78
79 // First, stop all services using ServiceHelper
80 ServiceHelper::processServices($bearsamppBins, function($serviceName, $service, $bin, $syntaxCheckCmd) use ($bearsamppLang) {
81 $name = ServiceHelper::getServiceDisplayName($bin, $service);
82
83 $this->splash->incrProgressBar();
84 $this->splash->setTextLoading(sprintf($bearsamppLang->getValue(Lang::LOADING_STOP_SERVICE), $name));
85
86 // Stop the service
88 });
89
90 // Then, start all services using ServiceHelper
91 ServiceHelper::processServices($bearsamppBins, function($serviceName, $service, $bin, $syntaxCheckCmd) use ($bearsamppLang) {
92 $name = ServiceHelper::getServiceDisplayName($bin, $service);
93
94 $this->splash->incrProgressBar();
95 $this->splash->setTextLoading(sprintf($bearsamppLang->getValue(Lang::LOADING_START_SERVICE), $name));
96
97 // Start the service
98 ServiceHelper::startService($bin, $syntaxCheckCmd, false);
99 });
100
101 // Final update
102 $this->splash->incrProgressBar();
103 $this->splash->setTextLoading($bearsamppLang->getValue(Lang::LOADING_COMPLETE));
104
105 // Close the splash screen and exit cleanly
106 $bearsamppWinbinder->destroyWindow($window);
107 $bearsamppWinbinder->reset();
108 exit(0);
109 }
const LOADING_COMPLETE
const LOADING_START_SERVICE
const LOADING_STOP_SERVICE
static getServiceDisplayName($bin, $service)
static stopService($service)
static startService($bin, $syntaxCheckCmd=null, $showErrors=true)
static processServices($bearsamppBins, callable $callback)

References $bearsamppBins, $bearsamppLang, exit, ServiceHelper\getServiceDisplayName(), Lang\LOADING_COMPLETE, Lang\LOADING_START_SERVICE, Lang\LOADING_STOP_SERVICE, ServiceHelper\processServices(), ServiceHelper\startService(), and ServiceHelper\stopService().

Field Documentation

◆ $processed

$processed = false
private

Definition at line 25 of file class.action.restartAllServices.php.

◆ $splash

$splash
private

Definition at line 20 of file class.action.restartAllServices.php.

◆ GAUGE_PER_SERVICE

const GAUGE_PER_SERVICE = 2

Gauge value for progress bar increments.

Definition at line 30 of file class.action.restartAllServices.php.


The documentation for this class was generated from the following file: