2024.8.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()

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

References $bearsamppBins, $port, BinApache\CMD_SYNTAX_CHECK, BinMariadb\CMD_SYNTAX_CHECK, BinMysql\CMD_SYNTAX_CHECK, create(), install(), restart(), BinApache\SERVICE_NAME, BinFilezilla\SERVICE_NAME, BinMailhog\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()

ActionService::create ( $service)
private

Creates a service.

Parameters
Win32Service$serviceThe service to create.

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

120 {
121 $service->create();
122 }

Referenced by __construct().

+ Here is the caller graph for this function:

◆ install()

ActionService::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 165 of file class.action.service.php.

166 {
167 Util::installService( $bin, $port, $syntaxCheckCmd, true );
168 }
static installService($bin, $port, $syntaxCheckCmd, $showWindow=false)

References $port, and Util\installService().

Referenced by __construct().

+ Here is the caller graph for this function:

◆ remove()

ActionService::remove ( $service,
$name )
private

Removes a service.

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

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

177 {
178 Util::removeService( $service, $name );
179 }
static removeService($service, $name)

References Util\removeService().

◆ restart()

ActionService::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 151 of file class.action.service.php.

152 {
153 if ( $bin->getService()->stop() ) {
154 $this->start( $bin, $syntaxCheckCmd );
155 }
156 }

References start().

Referenced by __construct().

+ Here is the caller graph for this function:

◆ start()

ActionService::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 130 of file class.action.service.php.

131 {
132 Util::startService( $bin, $syntaxCheckCmd, true );
133 }
static startService($bin, $syntaxCheckCmd, $showWindow=false)

References Util\startService().

Referenced by __construct(), and restart().

+ Here is the caller graph for this function:

◆ stop()

ActionService::stop ( $service)
private

Stops a service.

Parameters
Win32Service$serviceThe service to stop.

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

141 {
142 $service->stop();
143 }

Referenced by __construct().

+ Here is the caller graph for this function:

Field Documentation

◆ CREATE

const ActionService::CREATE = 'create'

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

Referenced by TplService\getActionCreate().

◆ INSTALL

◆ REMOVE

◆ RESTART

const ActionService::RESTART = 'restart'

◆ START

const ActionService::START = 'start'

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

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

◆ STOP

const ActionService::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: