Bearsampp 2026.3.26
API documentation
Loading...
Searching...
No Matches
ActionDebugBase Class Reference
Inheritance diagram for ActionDebugBase:

Public Member Functions

 __construct ($args)

Protected Member Functions

 getBinInstance ($bearsamppBins)
 getCommandMapping ()
 getServiceLangConstant ()
 hasContentKey ()
 isSyntaxCheckCommand ($command)

Detailed Description

Class ActionDebugBase

Base class for debugging actions across different services (MySQL, MariaDB, Apache, PostgreSQL). This class provides common functionality for executing debug commands and displaying their output. Child classes need to implement service-specific methods to define their behavior.

Since
2026.2.16

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

Constructor & Destructor Documentation

◆ __construct()

__construct ( $args)

Constructor for debug actions.

Parameters
array$argsAn array of arguments where the first element is the command to execute.

This constructor handles the common debugging workflow:

  1. Validates arguments
  2. Builds the caption based on the command
  3. Executes the command and retrieves output
  4. Handles syntax check results if applicable
  5. Displays output in editor or message box
Since
2026.2.16

Definition at line 75 of file class.action.debugBase.php.

76 {
77 global $bearsamppLang, $bearsamppBins, $bearsamppTools, $bearsamppWinbinder;
78
79 if (isset($args[0]) && !empty($args[0])) {
80 $editor = false;
81 $msgBoxError = false;
82
83 // Build base caption
84 $serviceLangConstant = $this->getServiceLangConstant();
85 $caption = $bearsamppLang->getValue(Lang::DEBUG) . ' ' .
86 $bearsamppLang->getValue(constant('Lang::' . $serviceLangConstant)) . ' - ';
87
88 // Get command mapping and determine caption suffix and editor flag
89 $commandMapping = $this->getCommandMapping();
90 $command = $args[0];
91
92 if (isset($commandMapping[$command])) {
93 $config = $commandMapping[$command];
94 $caption .= $bearsamppLang->getValue($config['lang']);
95 if (isset($config['editor']) && $config['editor']) {
96 $editor = true;
97 }
98 }
99 $caption .= ' (' . $command . ')';
100
101 // Execute the command and get output
102 $bin = $this->getBinInstance($bearsamppBins);
103 $debugOutput = $bin->getCmdLineOutput($command);
104
105 // Handle syntax check results (if applicable)
106 if ($this->isSyntaxCheckCommand($command)) {
107 if ($this->hasContentKey()) {
108 $msgBoxError = !$debugOutput['syntaxOk'];
109 $debugOutput['content'] = $debugOutput['syntaxOk'] ? 'Syntax OK !' : $debugOutput['content'];
110 }
111 }
112
113 // Extract content based on service type
114 $content = $this->hasContentKey() && is_array($debugOutput) ? $debugOutput['content'] : $debugOutput;
115
116 // Display the output
117 if ($editor) {
118 Util::openFileContent($caption, $content);
119 } else {
120 if ($msgBoxError) {
121 $bearsamppWinbinder->messageBoxError($content, $caption);
122 } else {
123 $bearsamppWinbinder->messageBoxInfo($content, $caption);
124 }
125 }
126 }
127 }
global $bearsamppBins
global $bearsamppLang
getBinInstance($bearsamppBins)
const DEBUG
static openFileContent($caption, $content)

References $bearsamppBins, $bearsamppLang, Lang\DEBUG, getBinInstance(), getCommandMapping(), getServiceLangConstant(), hasContentKey(), isSyntaxCheckCommand(), and Util\openFileContent().

Member Function Documentation

◆ getBinInstance()

getBinInstance ( $bearsamppBins)
abstractprotected

Get the binary instance for this service

Parameters
object$bearsamppBinsThe bins object containing all service binaries
Returns
object The specific binary instance (e.g., BinMysql, BinApache)
Since
2026.2.16

Reimplemented in ActionDebugApache, ActionDebugMariadb, ActionDebugMysql, and ActionDebugPostgresql.

References $bearsamppBins.

Referenced by __construct().

◆ getCommandMapping()

getCommandMapping ( )
abstractprotected

Get the command-to-caption mapping for this service Returns an array where keys are command constants and values are arrays with:

  • 'lang': the language constant for the caption
  • 'editor': boolean indicating if output should be shown in editor (default: false)
Returns
array Command mapping configuration
Since
2026.2.16

Reimplemented in ActionDebugApache, ActionDebugMariadb, ActionDebugMysql, and ActionDebugPostgresql.

Referenced by __construct(), and isSyntaxCheckCommand().

◆ getServiceLangConstant()

getServiceLangConstant ( )
abstractprotected

Get the service name for language strings (e.g., 'MYSQL', 'APACHE', 'MARIADB', 'POSTGRESQL')

Returns
string The language constant name for the service
Since
2026.2.16

Reimplemented in ActionDebugApache, ActionDebugMariadb, ActionDebugMysql, and ActionDebugPostgresql.

Referenced by __construct().

◆ hasContentKey()

hasContentKey ( )
protected

Check if the debug output has a 'content' key (for services that return arrays) or if it's a direct string (for services like PostgreSQL)

Returns
bool True if output is an array with 'content' key, false if direct string
Since
2026.2.16

Reimplemented in ActionDebugPostgresql.

Definition at line 56 of file class.action.debugBase.php.

57 {
58 return true;
59 }

Referenced by __construct().

◆ isSyntaxCheckCommand()

isSyntaxCheckCommand ( $command)
protected

Check if the given command is a syntax check command

Parameters
string$commandThe command to check
Returns
bool True if it's a syntax check command
Since
2026.2.16

Definition at line 136 of file class.action.debugBase.php.

137 {
138 $commandMapping = $this->getCommandMapping();
139 if (isset($commandMapping[$command])) {
140 return isset($commandMapping[$command]['syntaxCheck']) && $commandMapping[$command]['syntaxCheck'];
141 }
142 return false;
143 }

References getCommandMapping().

Referenced by __construct().


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