2024.8.23
Loading...
Searching...
No Matches
ActionSwitchPhpParam Class Reference

Public Member Functions

 __construct ($args)
 

Data Fields

const SWITCH_OFF = 'off'
 
const SWITCH_ON = 'on'
 

Detailed Description

Class ActionSwitchPhpParam

This class handles the switching of PHP parameters on and off. It modifies the PHP configuration file based on the provided arguments.

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

Constructor & Destructor Documentation

◆ __construct()

ActionSwitchPhpParam::__construct ( $args)

Constructor for ActionSwitchPhpParam.

Parameters
array$argsAn array containing the PHP setting name and the desired state ('on' or 'off').

Definition at line 26 of file class.action.switchPhpParam.php.

27 {
28 global $bearsamppLang, $bearsamppBins, $bearsamppWinbinder;
29
30 // Check if the required arguments are provided and not empty
31 if (isset($args[0]) && !empty($args[0]) && isset($args[1]) && !empty($args[1])) {
32 // Check if the PHP setting exists
33 if (!$bearsamppBins->getPhp()->isSettingExists($args[0])) {
34 $bearsamppWinbinder->messageBoxError(
35 sprintf($bearsamppLang->getValue(Lang::SWITCH_PHP_SETTING_NOT_FOUND), $args[0], $bearsamppBins->getPhp()->getVersion()),
37 );
38 return;
39 }
40
41 // Retrieve the current settings values
42 $settingsValues = $bearsamppBins->getPhp()->getSettingsValues();
43 if (isset($settingsValues[$args[0]])) {
44 $onContent = $args[0] . ' = ' . $settingsValues[$args[0]][0];
45 $offContent = $args[0] . ' = ' . $settingsValues[$args[0]][1];
46
47 // Read the current PHP configuration file content
48 $phpiniContent = file_get_contents($bearsamppBins->getPhp()->getConf());
49 if ($args[1] == self::SWITCH_ON) {
50 // Replace the off setting with the on setting
51 $phpiniContent = str_replace($offContent, $onContent, $phpiniContent);
52 } elseif ($args[1] == self::SWITCH_OFF) {
53 // Replace the on setting with the off setting
54 $phpiniContent = str_replace($onContent, $offContent, $phpiniContent);
55 }
56
57 // Write the updated content back to the PHP configuration file
58 file_put_contents($bearsamppBins->getPhp()->getConf(), $phpiniContent);
59 }
60 }
61 }
global $bearsamppBins
global $bearsamppLang
const SWITCH_PHP_SETTING_TITLE
const SWITCH_PHP_SETTING_NOT_FOUND

References $bearsamppBins, $bearsamppLang, Lang\SWITCH_PHP_SETTING_NOT_FOUND, and Lang\SWITCH_PHP_SETTING_TITLE.

Field Documentation

◆ SWITCH_OFF

const ActionSwitchPhpParam::SWITCH_OFF = 'off'

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

Referenced by TplAppPhp\getActionSwitchPhpSetting().

◆ SWITCH_ON

const ActionSwitchPhpParam::SWITCH_ON = 'on'

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

Referenced by TplAppPhp\getActionSwitchPhpSetting().


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