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

Public Member Functions

 __construct ($args)

Data Fields

const CREATE = 'create'
const INSTALL = 'install'
const REMOVE = 'remove'
const RESTART = 'restart'
const START = 'start'
const STOP = 'stop'

Private Member Functions

 create ($service)
 install ($bin, $port, $syntaxCheckCmd)
 remove ($service, $name)
 restart ($bin, $syntaxCheckCmd)
 start ($bin, $syntaxCheckCmd)
 stop ($service)

Detailed Description

Class ActionService Handles various actions related to services such as creating, starting, stopping, restarting, installing, and removing.

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

Constructor & Destructor Documentation

◆ __construct()

__construct ( $args)

ActionService constructor. Initializes the service action based on provided arguments.

Parameters
array$argsArguments for the service action.

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

31 {
32 global $bearsamppBins;
34
35 // Reload bins
36 $bearsamppBins->reload();
37
38 if (isset($args[0]) && !empty($args[0]) && isset($args[1]) && !empty($args[1])) {
39 $sName = $args[0];
40 $bin = null;
41 $port = 0;
42 $syntaxCheckCmd = null;
43
44 if ($sName == BinMailpit::SERVICE_NAME) {
45 $bin = $bearsamppBins->getMailpit();
46 $port = $bin->getSmtpPort();
47 } elseif ($sName == BinMemcached::SERVICE_NAME) {
48 $bin = $bearsamppBins->getMemcached();
49 $port = $bin->getPort();
50 } elseif ($sName == BinApache::SERVICE_NAME) {
51 $bin = $bearsamppBins->getApache();
52 $port = $bin->getPort();
53 $syntaxCheckCmd = BinApache::CMD_SYNTAX_CHECK;
54 } elseif ($sName == BinMysql::SERVICE_NAME) {
55 $bin = $bearsamppBins->getMysql();
56 $port = $bin->getPort();
57 $syntaxCheckCmd = BinMysql::CMD_SYNTAX_CHECK;
58 } elseif ($sName == BinMariadb::SERVICE_NAME) {
59 $bin = $bearsamppBins->getMariadb();
60 $port = $bin->getPort();
61 $syntaxCheckCmd = BinMariadb::CMD_SYNTAX_CHECK;
62 } elseif ($sName == BinPostgresql::SERVICE_NAME) {
63 $bin = $bearsamppBins->getPostgresql();
64 $port = $bin->getPort();
65 } elseif ($sName == BinXlight::SERVICE_NAME) {
66 $bin = $bearsamppBins->getXlight();
67 $port = $bin->getPort();
68 }
69
70 $name = $bin->getName();
71 $service = $bin->getService();
72
73 if (!empty($service) && $service instanceof Win32Service) {
74 if ($args[1] == self::CREATE) {
75 $this->create($service);
76 } elseif ($args[1] == self::START) {
77 $this->start($bin, $syntaxCheckCmd);
78 } elseif ($args[1] == self::STOP) {
79 $this->stop($service);
80 } elseif ($args[1] == self::RESTART) {
81 $this->restart($bin, $syntaxCheckCmd);
82 } elseif ($args[1] == self::INSTALL) {
83 if (!empty($port)) {
84 $this->install($bin, $port, $syntaxCheckCmd);
85 }
86 } elseif ($args[1] == self::REMOVE) {
87 $this->remove($service, $name);
88 }
89 }
90 }
91
93 }
global $bearsamppBins
$port
start($bin, $syntaxCheckCmd)
restart($bin, $syntaxCheckCmd)
install($bin, $port, $syntaxCheckCmd)
const CMD_SYNTAX_CHECK
const SERVICE_NAME
const CMD_SYNTAX_CHECK
static startLoading()
static stopLoading()

References $bearsamppBins, $port, BinApache\CMD_SYNTAX_CHECK, BinMariadb\CMD_SYNTAX_CHECK, BinMysql\CMD_SYNTAX_CHECK, create(), install(), restart(), BinApache\SERVICE_NAME, BinMailpit\SERVICE_NAME, BinMariadb\SERVICE_NAME, BinMemcached\SERVICE_NAME, BinMysql\SERVICE_NAME, BinPostgresql\SERVICE_NAME, BinXlight\SERVICE_NAME, start(), Util\startLoading(), stop(), and Util\stopLoading().

Here is the call graph for this function:

Member Function Documentation

◆ create()

create ( $service)
private

Creates a service.

Parameters
Win32Service$serviceThe service to create.

Definition at line 100 of file class.action.service.php.

101 {
102 $service->create();
103 }

Referenced by __construct().

Here is the caller graph for this function:

◆ install()

install ( $bin,
$port,
$syntaxCheckCmd )
private

Installs a service.

Parameters
mixed$binThe binary object of the service.
int$portThe port number for the service.
string | null$syntaxCheckCmdThe command to check syntax, if applicable.

Definition at line 155 of file class.action.service.php.

156 {
157 ServiceHelper::installService($bin, $port, $syntaxCheckCmd, true);
158 }
static installService($bin, $port, $syntaxCheckCmd, $showWindow=false)

References $port, and ServiceHelper\installService().

Referenced by __construct().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ remove()

remove ( $service,
$name )
private

Removes a service.

Parameters
Win32Service$serviceThe service to remove.
string$nameThe name of the service.

Definition at line 166 of file class.action.service.php.

167 {
168 ServiceHelper::removeService($service, $name);
169 }
static removeService($service, $name)

References ServiceHelper\removeService().

Here is the call graph for this function:

◆ restart()

restart ( $bin,
$syntaxCheckCmd )
private

Restarts a service.

Parameters
mixed$binThe binary object of the service.
string | null$syntaxCheckCmdThe command to check syntax, if applicable.

Definition at line 138 of file class.action.service.php.

139 {
140 // Update loading screen to show service is restarting
141 Util::updateLoadingText('Restarting ' . $bin->getName() . '...');
142
143 if ($bin->getService()->stop()) {
144 $this->start($bin, $syntaxCheckCmd);
145 }
146 }
static updateLoadingText($text)

References start(), and Util\updateLoadingText().

Referenced by __construct().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ start()

start ( $bin,
$syntaxCheckCmd )
private

Starts a service.

Parameters
mixed$binThe binary object of the service.
string | null$syntaxCheckCmdThe command to check syntax, if applicable.

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

112 {
113 // Update loading screen to show which service is starting
114 Util::updateLoadingText('Starting ' . $bin->getName() . '...');
115
116 ServiceHelper::startService($bin, $syntaxCheckCmd, true);
117 }
static startService($bin, $syntaxCheckCmd=null, $showWindow=false)

References ServiceHelper\startService(), and Util\updateLoadingText().

Referenced by __construct(), and restart().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ stop()

stop ( $service)
private

Stops a service.

Parameters
Win32Service$serviceThe service to stop.

Definition at line 124 of file class.action.service.php.

125 {
126 // Update loading screen to show which service is stopping
127 Util::updateLoadingText('Stopping ' . $service->getName() . '...');
128
129 $service->stop();
130 }

References Util\updateLoadingText().

Referenced by __construct().

Here is the call graph for this function:
Here is the caller graph for this function:

Field Documentation

◆ CREATE

const CREATE = 'create'

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

Referenced by TplService\getActionCreate().

◆ INSTALL

◆ REMOVE

◆ RESTART

const RESTART = 'restart'

◆ START

const START = 'start'

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

Referenced by TplService\getActionStart(), and TplService\getItemStart().

◆ STOP

const STOP = 'stop'

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

Referenced by TplService\getActionStop(), and TplService\getItemStop().


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