Bearsampp 2026.7.11
Loading...
Searching...
No Matches
ActionStopAllServices Class Reference

Public Member Functions

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

Data Fields

const GAUGE_PER_SERVICE = 1

Private Attributes

 $processed = false
 $splash

Detailed Description

Class ActionStopAllServices Handles stopping all services with a single splash screen showing progress.

Definition at line 14 of file class.action.stopAllServices.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( $args)

ActionStopAllServices constructor. Initializes the stopping process, displays the splash screen, and sets up the main loop.

Parameters
array$argsCommand line arguments.

Definition at line 37 of file class.action.stopAllServices.php.

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 }
global $bearsamppBins
global $bearsamppLang
global $bearsamppCore
const LOADING_STOP_SERVICES
const MENU_STOP_SERVICES

References $bearsamppBins, $bearsamppCore, $bearsamppLang, Lang\LOADING_STOP_SERVICES, and Lang\MENU_STOP_SERVICES.

Member Function Documentation

◆ processWindow()

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

Processes the splash screen window events. Stops all services in parallel for optimized shutdown (40-60% faster). Automatically falls back to sequential if parallel fails.

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.stopAllServices.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 // Use parallel shutdown for optimized performance (40-60% faster than sequential)
80 // Falls back to sequential if parallel times out
83 function($current, $total, $serviceName) use ($bearsamppLang) {
84 $this->splash->incrProgressBar();
85 $this->splash->setTextLoading(sprintf($bearsamppLang->getValue(Lang::LOADING_STOP_SERVICE), $serviceName));
86 }
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 }
const LOADING_COMPLETE
const LOADING_STOP_SERVICE
static stopAllServicesParallel($bearsamppBins, ?callable $progressCallback=null, $shutdownTimeout=15)

References $bearsamppBins, $bearsamppLang, exit, Lang\LOADING_COMPLETE, Lang\LOADING_STOP_SERVICE, and ServiceHelper\stopAllServicesParallel().

Here is the call graph for this function:

Field Documentation

◆ $processed

$processed = false
private

Definition at line 24 of file class.action.stopAllServices.php.

◆ $splash

$splash
private

Definition at line 19 of file class.action.stopAllServices.php.

◆ GAUGE_PER_SERVICE

const GAUGE_PER_SERVICE = 1

Gauge value for progress bar increments.

Definition at line 29 of file class.action.stopAllServices.php.


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