Bearsampp 2026.9.23
Loading...
Searching...
No Matches
ActionExt Class Reference

Public Member Functions

 __construct ($args)

Data Fields

const REFRESH = 'refresh'
const RELOAD = 'reload'
const START = 'start'
const STATUS_ERROR = 2
const STATUS_SUCCESS = 0
const STATUS_WARNING = 1
const STOP = 'stop'

Private Member Functions

 addLog ($data)
 getProcs ()
 procRefresh ($args)
 procReload ($args)
 procStart ($args)
 procStop ($args)
 sendLogs ()
 setStatus ($status)

Private Attributes

 $logs = ''
 $status = self::STATUS_SUCCESS

Detailed Description

Class ActionExt handles the execution of various extended actions.

Definition at line 13 of file class.action.ext.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( $args)

Constructor for the ActionExt class.

Parameters
array$argsThe command line arguments passed to the action.

Definition at line 41 of file class.action.ext.php.

42 {
43 if (!isset($args[0]) || empty($args[0])) {
44 $this->addLog('No args defined');
45 $this->addLog('Available args:');
46 foreach ($this->getProcs() as $proc) {
47 $this->addLog('- ' . $proc);
48 }
49 $this->setStatus(self::STATUS_ERROR);
50 $this->sendLogs();
51
52 return;
53 }
54
55 $action = $args[0];
56
57 $newArgs = array();
58 foreach ($args as $key => $arg) {
59 if ($key > 0) {
60 $newArgs[] = $arg;
61 }
62 }
63
64 $method = 'proc' . ucfirst($action);
65 if (!method_exists($this, $method)) {
66 $this->addLog('Unknown arg: ' . $action);
67 $this->addLog('Available args:');
68 foreach ($this->getProcs() as $procName => $procDesc) {
69 $this->addLog('- ' . $procName . ': ' . $procDesc);
70 }
71 $this->setStatus(self::STATUS_ERROR);
72 $this->sendLogs();
73
74 return;
75 }
76
77 call_user_func(array($this, $method), $newArgs);
78 $this->sendLogs();
79 }
$proc
Definition ajax.php:130
setStatus($status)

References $proc, addLog(), getProcs(), sendLogs(), and setStatus().

Here is the call graph for this function:

Member Function Documentation

◆ addLog()

addLog ( $data)
private

Adds a log entry to the logs.

Parameters
string$dataThe log entry to add.

Definition at line 101 of file class.action.ext.php.

102 {
103 $this->logs .= $data . "\n";
104 }

Referenced by __construct(), procRefresh(), procReload(), procStart(), and procStop().

Here is the caller graph for this function:

◆ getProcs()

getProcs ( )
private

Retrieves the list of available actions.

Returns
array The list of available actions.

Definition at line 86 of file class.action.ext.php.

87 {
88 return array(
89 self::START,
90 self::STOP,
91 self::RELOAD,
92 self::REFRESH
93 );
94 }

Referenced by __construct().

Here is the caller graph for this function:

◆ procRefresh()

procRefresh ( $args)
private

Refreshes the application by calling the reload action.

Parameters
array$argsThe command line arguments passed to the action.

Definition at line 220 of file class.action.ext.php.

221 {
222 global $bearsamppAction;
223
224 if (!Util::isLaunched()) {
225 $this->addLog(APP_TITLE . ' is not started.');
226 $this->setStatus(self::STATUS_ERROR);
227
228 return;
229 }
230
232 }
const RELOAD
if(is_file($bearsamppCacert)) $bearsamppAction
Definition root.php:189
const APP_TITLE
Definition root.php:19

References $bearsamppAction, addLog(), APP_TITLE, Action\RELOAD, and setStatus().

Here is the call graph for this function:

◆ procReload()

procReload ( $args)
private

Reloads the application by stopping and starting services.

Parameters
array$argsThe command line arguments passed to the action.

Definition at line 178 of file class.action.ext.php.

179 {
180 global $bearsamppRoot, $bearsamppBins, $bearsamppWinbinder;
181
182 if (!Util::isLaunched()) {
183 $this->addLog(APP_TITLE . ' is not started.');
184 $bearsamppWinbinder->exec(Path::getExeFilePath(), null, false);
185 $this->addLog('Start ' . APP_TITLE);
186 $this->setStatus(self::STATUS_WARNING);
187
188 return;
189 }
190
191 $this->addLog('Remove services');
192 foreach ($bearsamppBins->getServices() as $sName => $service) {
193 if ($service->delete()) {
194 $this->addLog('- ' . $sName . ': OK');
195 } else {
196 $this->addLog('- ' . $sName . ': KO');
197 $this->setStatus(self::STATUS_ERROR);
198 }
199 }
200
202
203 $this->addLog('Start services');
204 foreach ($bearsamppBins->getServices() as $sName => $service) {
205 $service->create();
206 if ($service->start()) {
207 $this->addLog('- ' . $sName . ': OK');
208 } else {
209 $this->addLog('- ' . $sName . ': KO');
210 $this->setStatus(self::STATUS_ERROR);
211 }
212 }
213 }
global $bearsamppBins
global $bearsamppRoot
static getExeFilePath($aetrayPath=false)
static killBins($refreshProcs=false)

References $bearsamppBins, $bearsamppRoot, addLog(), APP_TITLE, Path\getExeFilePath(), Win32Ps\killBins(), and setStatus().

Here is the call graph for this function:

◆ procStart()

procStart ( $args)
private

Starts the application.

Parameters
array$argsThe command line arguments passed to the action.

Definition at line 132 of file class.action.ext.php.

133 {
134 global $bearsamppRoot, $bearsamppWinbinder;
135
136 if (!Util::isLaunched()) {
137 $this->addLog('Starting ' . APP_TITLE);
138 $bearsamppWinbinder->exec(Path::getExeFilePath(), null, false);
139 } else {
140 $this->addLog(APP_TITLE . ' already started');
141 $this->setStatus(self::STATUS_WARNING);
142 }
143 }

References $bearsamppRoot, addLog(), APP_TITLE, Path\getExeFilePath(), and setStatus().

Here is the call graph for this function:

◆ procStop()

procStop ( $args)
private

Stops the application and removes services.

Parameters
array$argsThe command line arguments passed to the action.

Definition at line 150 of file class.action.ext.php.

151 {
152 global $bearsamppBins;
153
154 if (Util::isLaunched()) {
155 $this->addLog('Remove services');
156 foreach ($bearsamppBins->getServices() as $sName => $service) {
157 if ($service->delete()) {
158 $this->addLog('- ' . $sName . ': OK');
159 } else {
160 $this->addLog('- ' . $sName . ': KO');
161 $this->setStatus(self::STATUS_ERROR);
162 }
163 }
164
165 $this->addLog('Stop ' . APP_TITLE);
166 Batch::exitAppStandalone();
167 } else {
168 $this->addLog(APP_TITLE . ' already stopped');
169 $this->setStatus(self::STATUS_WARNING);
170 }
171 }

References $bearsamppBins, addLog(), APP_TITLE, and setStatus().

Here is the call graph for this function:

◆ sendLogs()

sendLogs ( )
private

Sends the logs as a JSON-encoded response.

Definition at line 119 of file class.action.ext.php.

120 {
121 echo json_encode(array(
122 'status' => $this->status,
123 'response' => $this->logs
124 ));
125 }

Referenced by __construct().

Here is the caller graph for this function:

◆ setStatus()

setStatus ( $status)
private

Sets the status of the action.

Parameters
int$statusThe status code to set.

Definition at line 111 of file class.action.ext.php.

112 {
113 $this->status = $status;
114 }

References $status.

Referenced by __construct(), procRefresh(), procReload(), procStart(), and procStop().

Here is the caller graph for this function:

Field Documentation

◆ $logs

$logs = ''
private

Definition at line 34 of file class.action.ext.php.

◆ $status

$status = self::STATUS_SUCCESS
private

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

Referenced by setStatus().

◆ REFRESH

const REFRESH = 'refresh'

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

◆ RELOAD

const RELOAD = 'reload'

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

◆ START

const START = 'start'

Definition at line 16 of file class.action.ext.php.

◆ STATUS_ERROR

const STATUS_ERROR = 2

Definition at line 22 of file class.action.ext.php.

◆ STATUS_SUCCESS

const STATUS_SUCCESS = 0

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

◆ STATUS_WARNING

const STATUS_WARNING = 1

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

◆ STOP

const STOP = 'stop'

Definition at line 17 of file class.action.ext.php.


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