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

Static Public Member Functions

static getActionChangeMemcachedPort ()
 
static getActionEnableMemcached ($enable)
 
static getActionInstallMemcachedService ()
 
static getActionRemoveMemcachedService ()
 
static getActionSwitchMemcachedVersion ($version)
 
static getMenuMemcached ()
 
static getMenuMemcachedService ()
 
static getMenuMemcachedVersions ()
 
static process ()
 

Data Fields

const ACTION_CHANGE_PORT = 'changeMemcachedPort'
 
const ACTION_ENABLE = 'enableMemcached'
 
const ACTION_INSTALL_SERVICE = 'installMemcachedService'
 
const ACTION_REMOVE_SERVICE = 'removeMemcachedService'
 
const ACTION_SWITCH_VERSION = 'switchMemcachedVersion'
 
const MENU = 'memcached'
 
const MENU_SERVICE = 'memcachedService'
 
const MENU_VERSIONS = 'memcachedVersions'
 

Detailed Description

Class TplAppMemcached

This class provides methods to generate menu items and actions for managing Memcached within the Bearsampp application. It includes functionalities for enabling/disabling Memcached, switching versions, changing ports, and managing services.

Definition at line 16 of file class.tpl.app.memcached.php.

Member Function Documentation

◆ getActionChangeMemcachedPort()

static TplAppMemcached::getActionChangeMemcachedPort ( )
static

Generates the action to change the Memcached port.

This method creates the action string for changing the Memcached port. It includes commands to reload the application after the action is performed.

@global object $bearsamppBins Provides access to system binaries and their configurations.

Returns
string The generated action string for changing the Memcached port.

Definition at line 245 of file class.tpl.app.memcached.php.

246 {
247 global $bearsamppBins;
248
249 return TplApp::getActionRun(Action::CHANGE_PORT, array($bearsamppBins->getMemcached()->getName())) . PHP_EOL .
251 }
global $bearsamppBins
const CHANGE_PORT
static getActionRun($action, $args=array(), $item=array(), $waitUntilTerminated=true)

References $bearsamppBins, Action\CHANGE_PORT, TplAppReload\getActionReload(), and TplApp\getActionRun().

◆ getActionEnableMemcached()

static TplAppMemcached::getActionEnableMemcached ( $enable)
static

Generates the action to enable or disable Memcached.

This method creates the action string for enabling or disabling Memcached. It includes commands to reload the application after the action is performed.

@global object $bearsamppBins Provides access to system binaries and their configurations.

Parameters
int$enableThe value indicating whether to enable or disable Memcached.
Returns
string The generated action string for enabling or disabling Memcached.

Definition at line 149 of file class.tpl.app.memcached.php.

150 {
151 global $bearsamppBins;
152
153 return TplApp::getActionRun(Action::ENABLE, array($bearsamppBins->getMemcached()->getName(), $enable)) . PHP_EOL .
155 }
const ENABLE

References $bearsamppBins, Action\ENABLE, TplAppReload\getActionReload(), and TplApp\getActionRun().

◆ getActionInstallMemcachedService()

static TplAppMemcached::getActionInstallMemcachedService ( )
static

Generates the action to install the Memcached service.

This method creates the action string for installing the Memcached service. It includes commands to reload the application after the action is performed.

Returns
string The generated action string for installing the Memcached service.

Definition at line 261 of file class.tpl.app.memcached.php.

References TplAppReload\getActionReload(), TplApp\getActionRun(), ActionService\INSTALL, Action\SERVICE, and BinMemcached\SERVICE_NAME.

◆ getActionRemoveMemcachedService()

static TplAppMemcached::getActionRemoveMemcachedService ( )
static

Generates the action to remove the Memcached service.

This method creates the action string for removing the Memcached service. It includes commands to reload the application after the action is performed.

Returns
string The generated action string for removing the Memcached service.

Definition at line 275 of file class.tpl.app.memcached.php.

References TplAppReload\getActionReload(), TplApp\getActionRun(), ActionService\REMOVE, Action\SERVICE, and BinMemcached\SERVICE_NAME.

◆ getActionSwitchMemcachedVersion()

static TplAppMemcached::getActionSwitchMemcachedVersion ( $version)
static

Generates the action to switch Memcached versions.

This method creates the action string for switching Memcached versions. It includes commands to reload the application after the action is performed.

@global object $bearsamppBins Provides access to system binaries and their configurations.

Parameters
string$versionThe version to switch to.
Returns
string The generated action string for switching Memcached versions.

Definition at line 168 of file class.tpl.app.memcached.php.

169 {
170 global $bearsamppBins;
171
172 return TplApp::getActionRun(Action::SWITCH_VERSION, array($bearsamppBins->getMemcached()->getName(), $version)) . PHP_EOL .
174 }
const SWITCH_VERSION

References $bearsamppBins, TplAppReload\getActionReload(), TplApp\getActionRun(), and Action\SWITCH_VERSION.

◆ getMenuMemcached()

static TplAppMemcached::getMenuMemcached ( )
static

Generates the menu items and actions for managing Memcached.

This method creates menu items for downloading Memcached, enabling/disabling it, switching versions, managing services, updating the environment PATH, and viewing logs. It uses the global language object to retrieve localized strings.

@global object $bearsamppRoot Provides access to the root path of the application. @global object $bearsamppBins Provides access to system binaries and their configurations. @global object $bearsamppLang Provides language support for retrieving language-specific values.

Returns
string The generated menu items and actions for managing Memcached.

Definition at line 59 of file class.tpl.app.memcached.php.

60 {
62 $resultItems = $resultActions = '';
63
64 $isEnabled = $bearsamppBins->getMemcached()->isEnable();
65
66 // Download
68 Util::getWebsiteUrl('module/memcached', '#releases'),
69 false,
71 ) . PHP_EOL;
72
73 // Enable
74 $tplEnable = TplApp::getActionMulti(
75 self::ACTION_ENABLE, array($isEnabled ? Config::DISABLED : Config::ENABLED),
76 array($bearsamppLang->getValue(Lang::MENU_ENABLE), $isEnabled ? TplAestan::GLYPH_CHECK : ''),
77 false, get_called_class()
78 );
79 $resultItems .= $tplEnable[TplApp::SECTION_CALL] . PHP_EOL;
80 $resultActions .= $tplEnable[TplApp::SECTION_CONTENT] . PHP_EOL;
81
82 if ($isEnabled) {
83 $resultItems .= TplAestan::getItemSeparator() . PHP_EOL;
84
85 // Versions
86 $tplVersions = TplApp::getMenu($bearsamppLang->getValue(Lang::VERSIONS), self::MENU_VERSIONS, get_called_class());
87 $resultItems .= $tplVersions[TplApp::SECTION_CALL] . PHP_EOL;
88 $resultActions .= $tplVersions[TplApp::SECTION_CONTENT] . PHP_EOL;
89
90 // Service
91 $tplService = TplApp::getMenu($bearsamppLang->getValue(Lang::SERVICE), self::MENU_SERVICE, get_called_class());
92 $resultItems .= $tplService[TplApp::SECTION_CALL] . PHP_EOL;
93 $resultActions .= $tplService[TplApp::SECTION_CONTENT];
94
95 // Update environment PATH
96 $resultItems .= TplAestan::getItemNotepad($bearsamppLang->getValue(Lang::MENU_UPDATE_ENV_PATH), $bearsamppRoot->getRootPath() . '/nssmEnvPaths.dat') . PHP_EOL;
97
98 // Log
99 $resultItems .= TplAestan::getItemNotepad($bearsamppLang->getValue(Lang::MENU_LOGS), $bearsamppBins->getMemcached()->getLog()) . PHP_EOL;
100 }
101
102 return $resultItems . PHP_EOL . $resultActions;
103 }
global $bearsamppLang
global $bearsamppRoot
const DISABLED
const MENU_LOGS
const VERSIONS
const MENU_UPDATE_ENV_PATH
const DOWNLOAD_MORE
const SERVICE
static getItemSeparator()
static getItemLink($caption, $link, $local=false, $glyph=self::GLYPH_WEB_PAGE)
static getItemNotepad($caption, $path)
static getActionMulti($action, $args=array(), $item=array(), $disabled=false, $class=false)
const SECTION_CALL
const SECTION_CONTENT
static getMenu($caption, $menu, $class)
static getWebsiteUrl($path='', $fragment='', $utmSource=true)

References $bearsamppBins, $bearsamppLang, $bearsamppRoot, Config\DISABLED, Lang\DOWNLOAD_MORE, Config\ENABLED, TplApp\getActionMulti(), TplAestan\getItemLink(), TplAestan\getItemNotepad(), TplAestan\getItemSeparator(), TplApp\getMenu(), Util\getWebsiteUrl(), TplAestan\GLYPH_BROWSER, TplAestan\GLYPH_CHECK, Lang\MENU_ENABLE, Lang\MENU_LOGS, Lang\MENU_UPDATE_ENV_PATH, TplApp\SECTION_CALL, TplApp\SECTION_CONTENT, Lang\SERVICE, and Lang\VERSIONS.

◆ getMenuMemcachedService()

static TplAppMemcached::getMenuMemcachedService ( )
static

Generates the menu items and actions for managing Memcached services.

This method creates menu items for starting, stopping, and restarting the Memcached service, as well as checking and changing the port, and installing or removing the service. It uses the global language object to retrieve localized strings.

@global object $bearsamppLang Provides language support for retrieving language-specific values. @global object $bearsamppBins Provides access to system binaries and their configurations.

Returns
string The generated menu items and actions for managing Memcached services.

Definition at line 188 of file class.tpl.app.memcached.php.

189 {
191
192 $tplChangePort = TplApp::getActionMulti(
193 self::ACTION_CHANGE_PORT, null,
195 false, get_called_class()
196 );
197
198 $isInstalled = $bearsamppBins->getMemcached()->getService()->isInstalled();
199
200 $result = TplAestan::getItemActionServiceStart($bearsamppBins->getMemcached()->getService()->getName()) . PHP_EOL .
201 TplAestan::getItemActionServiceStop($bearsamppBins->getMemcached()->getService()->getName()) . PHP_EOL .
202 TplAestan::getItemActionServiceRestart($bearsamppBins->getMemcached()->getService()->getName()) . PHP_EOL .
203 TplAestan::getItemSeparator() . PHP_EOL .
205 Action::CHECK_PORT, array($bearsamppBins->getMemcached()->getName(), $bearsamppBins->getMemcached()->getPort()),
206 array(sprintf($bearsamppLang->getValue(Lang::MENU_CHECK_PORT), $bearsamppBins->getMemcached()->getPort()), TplAestan::GLYPH_LIGHT)
207 ) . PHP_EOL .
208 $tplChangePort[TplApp::SECTION_CALL] . PHP_EOL;
209
210 if (!$isInstalled) {
211 $tplInstallService = TplApp::getActionMulti(
212 self::ACTION_INSTALL_SERVICE, null,
214 $isInstalled, get_called_class()
215 );
216
217 $result .= $tplInstallService[TplApp::SECTION_CALL] . PHP_EOL . PHP_EOL .
218 $tplInstallService[TplApp::SECTION_CONTENT] . PHP_EOL;
219 } else {
220 $tplRemoveService = TplApp::getActionMulti(
221 self::ACTION_REMOVE_SERVICE, null,
223 !$isInstalled, get_called_class()
224 );
225
226 $result .= $tplRemoveService[TplApp::SECTION_CALL] . PHP_EOL . PHP_EOL .
227 $tplRemoveService[TplApp::SECTION_CONTENT] . PHP_EOL;
228 }
229
230 $result .= $tplChangePort[TplApp::SECTION_CONTENT] . PHP_EOL;
231
232 return $result;
233 }
$result
const CHECK_PORT
const MENU_INSTALL_SERVICE
const MENU_REMOVE_SERVICE
const MENU_CHECK_PORT
const MENU_CHANGE_PORT
const GLYPH_SERVICE_REMOVE
static getItemActionServiceStop($service)
static getItemActionServiceStart($service)
static getItemActionServiceRestart($service)
const GLYPH_SERVICE_INSTALL

References $bearsamppBins, $bearsamppLang, $result, Action\CHECK_PORT, TplApp\getActionMulti(), TplApp\getActionRun(), TplAestan\getItemActionServiceRestart(), TplAestan\getItemActionServiceStart(), TplAestan\getItemActionServiceStop(), TplAestan\getItemSeparator(), TplAestan\GLYPH_LIGHT, TplAestan\GLYPH_NETWORK, TplAestan\GLYPH_SERVICE_INSTALL, TplAestan\GLYPH_SERVICE_REMOVE, Lang\MENU_CHANGE_PORT, Lang\MENU_CHECK_PORT, Lang\MENU_INSTALL_SERVICE, Lang\MENU_REMOVE_SERVICE, TplApp\SECTION_CALL, and TplApp\SECTION_CONTENT.

◆ getMenuMemcachedVersions()

static TplAppMemcached::getMenuMemcachedVersions ( )
static

Generates the menu items and actions for switching Memcached versions.

This method creates menu items for each available Memcached version and defines the actions to be taken when a version is selected. It uses the global language object to retrieve localized strings.

@global object $bearsamppBins Provides access to system binaries and their configurations.

Returns
string The generated menu items and actions for switching Memcached versions.

Definition at line 115 of file class.tpl.app.memcached.php.

116 {
117 global $bearsamppBins;
118 $items = '';
119 $actions = '';
120
121 foreach ($bearsamppBins->getMemcached()->getVersionList() as $version) {
122 $tplSwitchMemcachedVersion = TplApp::getActionMulti(
123 self::ACTION_SWITCH_VERSION, array($version),
124 array($version, $version == $bearsamppBins->getMemcached()->getVersion() ? TplAestan::GLYPH_CHECK : ''),
125 false, get_called_class()
126 );
127
128 // Item
129 $items .= $tplSwitchMemcachedVersion[TplApp::SECTION_CALL] . PHP_EOL;
130
131 // Action
132 $actions .= PHP_EOL . $tplSwitchMemcachedVersion[TplApp::SECTION_CONTENT];
133 }
134
135 return $items . $actions;
136 }

References $bearsamppBins, TplApp\getActionMulti(), TplAestan\GLYPH_CHECK, TplApp\SECTION_CALL, and TplApp\SECTION_CONTENT.

◆ process()

static TplAppMemcached::process ( )
static

Generates the menu item for enabling/disabling Memcached.

This method creates a menu item for enabling or disabling Memcached and defines the actions to be taken when the menu item is selected. It uses the global language object to retrieve the localized string for Memcached.

@global object $bearsamppLang Provides language support for retrieving language-specific values. @global object $bearsamppBins Provides access to system binaries and their configurations.

Returns
array The generated menu item for enabling/disabling Memcached.

Definition at line 40 of file class.tpl.app.memcached.php.

41 {
43
44 return TplApp::getMenuEnable($bearsamppLang->getValue(Lang::MEMCACHED), self::MENU, get_called_class(), $bearsamppBins->getMemcached()->isEnable());
45 }
const MEMCACHED
static getMenuEnable($caption, $menu, $class, $enabled=true)

References $bearsamppBins, $bearsamppLang, TplApp\getMenuEnable(), and Lang\MEMCACHED.

Referenced by TplApp\getSectionMenuLeft().

+ Here is the caller graph for this function:

Field Documentation

◆ ACTION_CHANGE_PORT

const TplAppMemcached::ACTION_CHANGE_PORT = 'changeMemcachedPort'

Definition at line 25 of file class.tpl.app.memcached.php.

◆ ACTION_ENABLE

const TplAppMemcached::ACTION_ENABLE = 'enableMemcached'

Definition at line 23 of file class.tpl.app.memcached.php.

◆ ACTION_INSTALL_SERVICE

const TplAppMemcached::ACTION_INSTALL_SERVICE = 'installMemcachedService'

Definition at line 26 of file class.tpl.app.memcached.php.

◆ ACTION_REMOVE_SERVICE

const TplAppMemcached::ACTION_REMOVE_SERVICE = 'removeMemcachedService'

Definition at line 27 of file class.tpl.app.memcached.php.

◆ ACTION_SWITCH_VERSION

const TplAppMemcached::ACTION_SWITCH_VERSION = 'switchMemcachedVersion'

Definition at line 24 of file class.tpl.app.memcached.php.

◆ MENU

const TplAppMemcached::MENU = 'memcached'

Definition at line 19 of file class.tpl.app.memcached.php.

◆ MENU_SERVICE

const TplAppMemcached::MENU_SERVICE = 'memcachedService'

Definition at line 21 of file class.tpl.app.memcached.php.

◆ MENU_VERSIONS

const TplAppMemcached::MENU_VERSIONS = 'memcachedVersions'

Definition at line 20 of file class.tpl.app.memcached.php.


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