Bearsampp 2026.5.5
Loading...
Searching...
No Matches
ActionExec Class Reference

Public Member Functions

 __construct ($args)

Data Fields

const QUIT = 'quit'
const RESTART = 'restart'

Detailed Description

Class ActionExec

This class handles the execution of specific actions based on the content of a file. The actions include quitting the application or reloading it. The actions are read from a file whose path is provided by the global $bearsamppCore object.

Definition at line 18 of file class.action.exec.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( $args)

ActionExec constructor.

This constructor reads the action from a file specified by $bearsamppCore->getExec(). If the action is 'quit', it calls Batch\exitApp(). If the action is 'restart', it calls Batch\restartApp(). After executing the action, it deletes the action file.

Parameters
array$argsArguments passed to the constructor (not used in the current implementation).

Definition at line 39 of file class.action.exec.php.

40 {
41 global $bearsamppCore;
42
43 Log::trace('ActionExec constructor called');
44
45 $execFile = $bearsamppCore->getExec();
46 Log::trace('Checking for exec file: ' . $execFile);
47
48 if (file_exists($execFile)) {
49 Log::trace('Exec file exists');
50
51 $action = file_get_contents($execFile);
52 Log::trace('Action read from exec file: "' . $action . '"');
53
54 if ($action == self::QUIT) {
55 Log::trace('Executing quit action');
57 } elseif ($action == self::RESTART) {
58 Log::trace('Executing restart action');
60 } else {
61 Log::trace('Unknown action: "' . $action . '"');
62 }
63
64 // Do NOT delete the exec file yet if it's a restart,
65 // as we need the next instance to know it's a restart.
66 // ActionStartup will handle the unlinking.
67 if ($action != self::RESTART) {
68 Log::trace('Deleting exec file');
69 $unlinkResult = @unlink($execFile);
70 Log::trace('Unlink result: ' . ($unlinkResult ? 'success' : 'failed'));
71 }
72 } else {
73 Log::trace('Exec file does not exist: ' . $execFile);
74 }
75 }
global $bearsamppCore
static exitApp($restart=false)
static restartApp()
static trace($data, $file=null)

References $bearsamppCore, Batch\exitApp(), Batch\restartApp(), and Log\trace().

Field Documentation

◆ QUIT

const QUIT = 'quit'

Constant representing the 'quit' action.

Definition at line 23 of file class.action.exec.php.

◆ RESTART

const RESTART = 'restart'

Constant representing the 'reload' action.

Definition at line 28 of file class.action.exec.php.

Referenced by ActionManualRestart\__construct(), and ActionStartup\processWindow().


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