Bearsampp 2025.8.29
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 }
48 elseif ( $sName == BinMemcached::SERVICE_NAME ) {
49 $bin = $bearsamppBins->getMemcached();
50 $port = $bin->getPort();
51 }
52 elseif ( $sName == BinApache::SERVICE_NAME ) {
53 $bin = $bearsamppBins->getApache();
54 $port = $bin->getPort();
55 $syntaxCheckCmd = BinApache::CMD_SYNTAX_CHECK;
56 }
57 elseif ( $sName == BinMysql::SERVICE_NAME ) {
58 $bin = $bearsamppBins->getMysql();
59 $port = $bin->getPort();
60 $syntaxCheckCmd = BinMysql::CMD_SYNTAX_CHECK;
61 }
62 elseif ( $sName == BinMariadb::SERVICE_NAME ) {
63 $bin = $bearsamppBins->getMariadb();
64 $port = $bin->getPort();
65 $syntaxCheckCmd = BinMariadb::CMD_SYNTAX_CHECK;
66 }
67 elseif ( $sName == BinPostgresql::SERVICE_NAME ) {
68 $bin = $bearsamppBins->getPostgresql();
69 $port = $bin->getPort();
70 }
71 elseif ( $sName == BinXlight::SERVICE_NAME ) {
72 $bin = $bearsamppBins->getXlight();
73 $port = $bin->getPort();
74 }
75
76 $name = $bin->getName();
77 $service = $bin->getService();
78
79 if ( !empty( $service ) && $service instanceof Win32Service ) {
80 if ( $args[1] == self::CREATE ) {
81 $this->create( $service );
82 }
83 elseif ( $args[1] == self::START ) {
84 $this->start( $bin, $syntaxCheckCmd );
85 }
86 elseif ( $args[1] == self::STOP ) {
87 $this->stop( $service );
88 }
89 elseif ( $args[1] == self::RESTART ) {
90 $this->restart( $bin, $syntaxCheckCmd );
91 }
92 elseif ( $args[1] == self::INSTALL ) {
93 if ( !empty( $port ) ) {
94 $this->install( $bin, $port, $syntaxCheckCmd );
95 }
96 }
97 elseif ( $args[1] == self::REMOVE ) {
98 $this->remove( $service, $name );
99 }
100 }
101 }
102
104 }
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().

Member Function Documentation

◆ create()

create ( $service)
private

Creates a service.

Parameters
Win32Service$serviceThe service to create.

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

112 {
113 $service->create();
114 }

Referenced by __construct().

◆ 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 157 of file class.action.service.php.

158 {
159 Util::installService( $bin, $port, $syntaxCheckCmd, true );
160 }
static installService($bin, $port, $syntaxCheckCmd, $showWindow=false)

References $port, and Util\installService().

Referenced by __construct().

◆ remove()

remove ( $service,
$name )
private

Removes a service.

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

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

169 {
170 Util::removeService( $service, $name );
171 }
static removeService($service, $name)

References Util\removeService().

◆ 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 143 of file class.action.service.php.

144 {
145 if ( $bin->getService()->stop() ) {
146 $this->start( $bin, $syntaxCheckCmd );
147 }
148 }

References start().

Referenced by __construct().

◆ 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 122 of file class.action.service.php.

123 {
124 Util::startService( $bin, $syntaxCheckCmd, true );
125 }
static startService($bin, $syntaxCheckCmd, $showWindow=false)

References Util\startService().

Referenced by __construct(), and restart().

◆ stop()

stop ( $service)
private

Stops a service.

Parameters
Win32Service$serviceThe service to stop.

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

133 {
134 $service->stop();
135 }

Referenced by __construct().

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: