Bearsampp 2026.9.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()

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.

Returns
string The generated action string for changing the Memcached port. @global object $bearsamppBins Provides access to system binaries and their configurations.

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

260 {
261 global $bearsamppBins;
262
263 return TplApp::getActionRun(Action::CHANGE_PORT, array($bearsamppBins->getMemcached()->getName())) . PHP_EOL .
265 }
global $bearsamppBins
const CHANGE_PORT
static getActionRun($action, $args=array(), $item=array(), $waitUntilTerminated=true)

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

Here is the call graph for this function:

◆ getActionEnableMemcached()

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.

Parameters
int$enableThe value indicating whether to enable or disable Memcached.
Returns
string The generated action string for enabling or disabling Memcached. @global object $bearsamppBins Provides access to system binaries and their configurations.

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

156 {
157 global $bearsamppBins;
158
159 return TplApp::getActionRun(Action::ENABLE, array($bearsamppBins->getMemcached()->getName(), $enable)) . PHP_EOL .
161 }
const ENABLE

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

Here is the call graph for this function:

◆ getActionInstallMemcachedService()

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 275 of file class.tpl.app.memcached.php.

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

Here is the call graph for this function:

◆ getActionRemoveMemcachedService()

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 289 of file class.tpl.app.memcached.php.

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

Here is the call graph for this function:

◆ getActionSwitchMemcachedVersion()

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.

Parameters
string$versionThe version to switch to.
Returns
string The generated action string for switching Memcached versions. @global object $bearsamppBins Provides access to system binaries and their configurations.

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

176 {
177 global $bearsamppBins;
178
179 return TplApp::getActionRun(Action::SWITCH_VERSION, array($bearsamppBins->getMemcached()->getName(), $version)) . PHP_EOL .
181 }
const SWITCH_VERSION

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

Here is the call graph for this function:

◆ getMenuMemcached()

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.

Returns
string The generated menu items and actions for managing Memcached. @global object $bearsamppBins Provides access to system binaries and their configurations. @global object $bearsamppLang Provides language support for retrieving language-specific values.

@global object $bearsamppRoot Provides access to the root path of the application.

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

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

References $bearsamppBins, $bearsamppLang, $bearsamppRoot, Config\DISABLED, Lang\DOWNLOAD_MORE, Config\ENABLED, TplApp\getActionMulti(), TplAestan\getItemLink(), TplAestan\getItemNotepad(), TplAestan\getItemSeparator(), TplApp\getMenu(), Path\getRootPath(), HttpClient\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.

Here is the call graph for this function:

◆ getMenuMemcachedService()

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.

Returns
string The generated menu items and actions for managing Memcached services. @global object $bearsamppBins Provides access to system binaries and their configurations.

@global object $bearsamppLang Provides language support for retrieving language-specific values.

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

196 {
198
199 $tplChangePort = TplApp::getActionMulti(
200 self::ACTION_CHANGE_PORT,
201 null,
203 false,
204 get_called_class()
205 );
206
207 $isInstalled = $bearsamppBins->getMemcached()->getService()->isInstalled();
208
209 $result = TplAestan::getItemActionServiceStart($bearsamppBins->getMemcached()->getService()->getName()) . PHP_EOL .
210 TplAestan::getItemActionServiceStop($bearsamppBins->getMemcached()->getService()->getName()) . PHP_EOL .
211 TplAestan::getItemActionServiceRestart($bearsamppBins->getMemcached()->getService()->getName()) . PHP_EOL .
212 TplAestan::getItemSeparator() . PHP_EOL .
215 array($bearsamppBins->getMemcached()->getName(), $bearsamppBins->getMemcached()->getPort()),
216 array(sprintf($bearsamppLang->getValue(Lang::MENU_CHECK_PORT), $bearsamppBins->getMemcached()->getPort()), TplAestan::GLYPH_LIGHT)
217 ) . PHP_EOL .
218 $tplChangePort[TplApp::SECTION_CALL] . PHP_EOL;
219
220 if (!$isInstalled) {
221 $tplInstallService = TplApp::getActionMulti(
222 self::ACTION_INSTALL_SERVICE,
223 null,
225 $isInstalled,
226 get_called_class()
227 );
228
229 $result .= $tplInstallService[TplApp::SECTION_CALL] . PHP_EOL . PHP_EOL .
230 $tplInstallService[TplApp::SECTION_CONTENT] . PHP_EOL;
231 } else {
232 $tplRemoveService = TplApp::getActionMulti(
233 self::ACTION_REMOVE_SERVICE,
234 null,
236 !$isInstalled,
237 get_called_class()
238 );
239
240 $result .= $tplRemoveService[TplApp::SECTION_CALL] . PHP_EOL . PHP_EOL .
241 $tplRemoveService[TplApp::SECTION_CONTENT] . PHP_EOL;
242 }
243
244 $result .= $tplChangePort[TplApp::SECTION_CONTENT] . PHP_EOL;
245
246 return $result;
247 }
$result
const CHECK_PORT
const MENU_CHANGE_PORT
const MENU_INSTALL_SERVICE
const MENU_REMOVE_SERVICE
const MENU_CHECK_PORT
const GLYPH_SERVICE_REMOVE
static getItemActionServiceStop($service)
const GLYPH_SERVICE_INSTALL
static getItemActionServiceStart($service)
static getItemActionServiceRestart($service)

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.

Here is the call graph for this function:

◆ getMenuMemcachedVersions()

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.

Returns
string The generated menu items and actions for switching Memcached versions. @global object $bearsamppBins Provides access to system binaries and their configurations.

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

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

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

Here is the call graph for this function:

◆ process()

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.

Returns
array The generated menu item for enabling/disabling Memcached. @global object $bearsamppBins Provides access to system binaries and their configurations.

@global object $bearsamppLang Provides language support for retrieving language-specific values.

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 call graph for this function:
Here is the caller graph for this function:

Field Documentation

◆ ACTION_CHANGE_PORT

const ACTION_CHANGE_PORT = 'changeMemcachedPort'

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

◆ ACTION_ENABLE

const ACTION_ENABLE = 'enableMemcached'

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

◆ ACTION_INSTALL_SERVICE

const ACTION_INSTALL_SERVICE = 'installMemcachedService'

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

◆ ACTION_REMOVE_SERVICE

const ACTION_REMOVE_SERVICE = 'removeMemcachedService'

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

◆ ACTION_SWITCH_VERSION

const ACTION_SWITCH_VERSION = 'switchMemcachedVersion'

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

◆ MENU

const MENU = 'memcached'

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

◆ MENU_SERVICE

const MENU_SERVICE = 'memcachedService'

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

◆ MENU_VERSIONS

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