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

Static Public Member Functions

static getActionChangeMailhogPort ()
 
static getActionEnableMailhog ($enable)
 
static getActionInstallMailhogService ()
 
static getActionRemoveMailhogService ()
 
static getActionSwitchMailhogVersion ($version)
 
static getMenuMailhog ()
 
static getMenuMailhogService ()
 
static getMenuMailhogVersions ()
 
static process ()
 

Data Fields

const ACTION_CHANGE_PORT = 'changeMailhogPort'
 
const ACTION_ENABLE = 'enableMailhog'
 
const ACTION_INSTALL_SERVICE = 'installMailhogService'
 
const ACTION_REMOVE_SERVICE = 'removeMailhogService'
 
const ACTION_SWITCH_VERSION = 'switchMailhogVersion'
 
const MENU = 'mailhog'
 
const MENU_SERVICE = 'mailhogService'
 
const MENU_VERSIONS = 'mailhogVersions'
 

Detailed Description

Class TplAppMailhog

This class provides methods to generate menus and actions for managing Mailhog within the Bearsampp application. It includes functionalities for enabling/disabling Mailhog, switching versions, changing ports, and managing the service.

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

Member Function Documentation

◆ getActionChangeMailhogPort()

static TplAppMailhog::getActionChangeMailhogPort ( )
static

Generates the action to change the Mailhog port.

This method creates the action string for changing the Mailhog port and includes a command to reload the application.

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

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

Definition at line 248 of file class.tpl.app.mailhog.php.

249 {
250 global $bearsamppBins;
251
252 return TplApp::getActionRun(Action::CHANGE_PORT, array($bearsamppBins->getMailhog()->getName())) . PHP_EOL .
254 }
global $bearsamppBins
const CHANGE_PORT
static getActionRun($action, $args=array(), $item=array(), $waitUntilTerminated=true)

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

◆ getActionEnableMailhog()

static TplAppMailhog::getActionEnableMailhog ( $enable)
static

Generates the action to enable or disable Mailhog.

This method creates the action string for enabling or disabling Mailhog and includes a command to reload the application.

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

Parameters
int$enableThe enable flag (1 to enable, 0 to disable).
Returns
string The generated action string for enabling or disabling Mailhog.

Definition at line 153 of file class.tpl.app.mailhog.php.

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

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

◆ getActionInstallMailhogService()

static TplAppMailhog::getActionInstallMailhogService ( )
static

Generates the action to install the Mailhog service.

This method creates the action string for installing the Mailhog service and includes a command to reload the application.

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

Definition at line 263 of file class.tpl.app.mailhog.php.

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

◆ getActionRemoveMailhogService()

static TplAppMailhog::getActionRemoveMailhogService ( )
static

Generates the action to remove the Mailhog service.

This method creates the action string for removing the Mailhog service and includes a command to reload the application.

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

Definition at line 276 of file class.tpl.app.mailhog.php.

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

◆ getActionSwitchMailhogVersion()

static TplAppMailhog::getActionSwitchMailhogVersion ( $version)
static

Generates the action to switch the Mailhog version.

This method creates the action string for switching the Mailhog version and includes a command to reload the application.

@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 the Mailhog version.

Definition at line 171 of file class.tpl.app.mailhog.php.

172 {
173 global $bearsamppBins;
174
175 return TplApp::getActionRun(Action::SWITCH_VERSION, array($bearsamppBins->getMailhog()->getName(), $version)) . PHP_EOL .
177 }
const SWITCH_VERSION

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

◆ getMenuMailhog()

static TplAppMailhog::getMenuMailhog ( )
static

Generates the Mailhog menu.

This method creates the menu items and associated actions for Mailhog, including options for downloading, enabling, switching versions, managing the service, and viewing logs.

@global object $bearsamppRoot Provides access to the root path of the application. @global object $bearsamppConfig Provides access to the application configuration. @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 Mailhog menu items and actions.

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

60 {
62 $resultItems = $resultActions = '';
63
64 $isEnabled = $bearsamppBins->getMailhog()->isEnable();
65
66 // Download
67 $resultItems .= TplAestan::getItemLink(
69 Util::getWebsiteUrl('module/mailhog', '#releases'),
70 false,
72 ) . PHP_EOL;
73
74 // Enable
75 $tplEnable = TplApp::getActionMulti(
76 self::ACTION_ENABLE, array($isEnabled ? Config::DISABLED : Config::ENABLED),
77 array($bearsamppLang->getValue(Lang::MENU_ENABLE), $isEnabled ? TplAestan::GLYPH_CHECK : ''),
78 false, get_called_class()
79 );
80 $resultItems .= $tplEnable[TplApp::SECTION_CALL] . PHP_EOL;
81 $resultActions .= $tplEnable[TplApp::SECTION_CONTENT] . PHP_EOL;
82
83 if ($isEnabled) {
84 $resultItems .= TplAestan::getItemSeparator() . PHP_EOL;
85
86 // Versions
87 $tplVersions = TplApp::getMenu($bearsamppLang->getValue(Lang::VERSIONS), self::MENU_VERSIONS, get_called_class());
88 $resultItems .= $tplVersions[TplApp::SECTION_CALL] . PHP_EOL;
89 $resultActions .= $tplVersions[TplApp::SECTION_CONTENT] . PHP_EOL;
90
91 // Service
92 $tplService = TplApp::getMenu($bearsamppLang->getValue(Lang::SERVICE), self::MENU_SERVICE, get_called_class());
93 $resultItems .= $tplService[TplApp::SECTION_CALL] . PHP_EOL;
94 $resultActions .= $tplService[TplApp::SECTION_CONTENT] . PHP_EOL;
95
96 // Web page
97 $resultItems .= TplAestan::getItemExe(
99 $bearsamppConfig->getBrowser(),
101 $bearsamppRoot->getLocalUrl() . ':' . $bearsamppBins->getMailhog()->getUiPort()
102 ) . PHP_EOL;
103
104 // Log
105 $resultItems .= TplAestan::getItemNotepad($bearsamppLang->getValue(Lang::MENU_LOGS), $bearsamppBins->getMailhog()->getLog()) . PHP_EOL;
106 }
107
108 return $resultItems . PHP_EOL . $resultActions;
109 }
global $bearsamppLang
global $bearsamppRoot
const DISABLED
const MENU_LOGS
const VERSIONS
const MAILHOG
const DOWNLOAD_MORE
const SERVICE
static getItemSeparator()
static getItemLink($caption, $link, $local=false, $glyph=self::GLYPH_WEB_PAGE)
static getItemExe($caption, $exe, $glyph, $params=null)
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)
global $bearsamppConfig
Definition homepage.php:26

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

◆ getMenuMailhogService()

static TplAppMailhog::getMenuMailhogService ( )
static

Generates the Mailhog service menu.

This method creates the menu items and associated actions for managing the Mailhog service, including starting, stopping, restarting, changing ports, and installing or removing the service.

@global object $bearsamppRoot Provides access to the root path of the application. @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 Mailhog service menu items and actions.

Definition at line 191 of file class.tpl.app.mailhog.php.

192 {
194
195 $tplChangePort = TplApp::getActionMulti(
196 self::ACTION_CHANGE_PORT, null,
198 false, get_called_class()
199 );
200
201 $isInstalled = $bearsamppBins->getMailhog()->getService()->isInstalled();
202
203 $result = TplAestan::getItemActionServiceStart($bearsamppBins->getMailhog()->getService()->getName()) . PHP_EOL .
204 TplAestan::getItemActionServiceStop($bearsamppBins->getMailhog()->getService()->getName()) . PHP_EOL .
205 TplAestan::getItemActionServiceRestart($bearsamppBins->getMailhog()->getService()->getName()) . PHP_EOL .
206 TplAestan::getItemSeparator() . PHP_EOL .
208 Action::CHECK_PORT, array($bearsamppBins->getMailhog()->getName(), $bearsamppBins->getMailhog()->getSmtpPort()),
209 array(sprintf($bearsamppLang->getValue(Lang::MENU_CHECK_PORT), $bearsamppBins->getMailhog()->getSmtpPort()), TplAestan::GLYPH_LIGHT)
210 ) . PHP_EOL .
211 $tplChangePort[TplApp::SECTION_CALL] . PHP_EOL .
212 TplAestan::getItemNotepad($bearsamppLang->getValue(Lang::MENU_UPDATE_ENV_PATH), $bearsamppRoot->getRootPath() . '/nssmEnvPaths.dat') . PHP_EOL;
213
214 if (!$isInstalled) {
215 $tplInstallService = TplApp::getActionMulti(
216 self::ACTION_INSTALL_SERVICE, null,
218 $isInstalled, get_called_class()
219 );
220
221 $result .= $tplInstallService[TplApp::SECTION_CALL] . PHP_EOL . PHP_EOL .
222 $tplInstallService[TplApp::SECTION_CONTENT] . PHP_EOL;
223 } else {
224 $tplRemoveService = TplApp::getActionMulti(
225 self::ACTION_REMOVE_SERVICE, null,
227 !$isInstalled, get_called_class()
228 );
229
230 $result .= $tplRemoveService[TplApp::SECTION_CALL] . PHP_EOL . PHP_EOL .
231 $tplRemoveService[TplApp::SECTION_CONTENT] . PHP_EOL;
232 }
233
234 $result .= $tplChangePort[TplApp::SECTION_CONTENT] . PHP_EOL;
235
236 return $result;
237 }
$result
const CHECK_PORT
const MENU_INSTALL_SERVICE
const MENU_UPDATE_ENV_PATH
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, $bearsamppRoot, $result, Action\CHECK_PORT, TplApp\getActionMulti(), TplApp\getActionRun(), TplAestan\getItemActionServiceRestart(), TplAestan\getItemActionServiceStart(), TplAestan\getItemActionServiceStop(), TplAestan\getItemNotepad(), 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, Lang\MENU_UPDATE_ENV_PATH, TplApp\SECTION_CALL, and TplApp\SECTION_CONTENT.

◆ getMenuMailhogVersions()

static TplAppMailhog::getMenuMailhogVersions ( )
static

Generates the Mailhog versions menu.

This method creates the menu items and associated actions for switching between different versions of Mailhog.

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

Returns
string The generated Mailhog versions menu items and actions.

Definition at line 120 of file class.tpl.app.mailhog.php.

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

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

◆ process()

static TplAppMailhog::process ( )
static

Processes the Mailhog menu.

This method generates the menu for enabling or disabling Mailhog. It uses the global language object to retrieve the localized string for Mailhog.

@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 for enabling or disabling Mailhog.

Definition at line 39 of file class.tpl.app.mailhog.php.

40 {
42
43 return TplApp::getMenuEnable($bearsamppLang->getValue(Lang::MAILHOG), self::MENU, get_called_class(), $bearsamppBins->getMailhog()->isEnable());
44 }
static getMenuEnable($caption, $menu, $class, $enabled=true)

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

Referenced by TplApp\getSectionMenuLeft().

+ Here is the caller graph for this function:

Field Documentation

◆ ACTION_CHANGE_PORT

const TplAppMailhog::ACTION_CHANGE_PORT = 'changeMailhogPort'

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

◆ ACTION_ENABLE

const TplAppMailhog::ACTION_ENABLE = 'enableMailhog'

Definition at line 22 of file class.tpl.app.mailhog.php.

◆ ACTION_INSTALL_SERVICE

const TplAppMailhog::ACTION_INSTALL_SERVICE = 'installMailhogService'

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

◆ ACTION_REMOVE_SERVICE

const TplAppMailhog::ACTION_REMOVE_SERVICE = 'removeMailhogService'

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

◆ ACTION_SWITCH_VERSION

const TplAppMailhog::ACTION_SWITCH_VERSION = 'switchMailhogVersion'

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

◆ MENU

const TplAppMailhog::MENU = 'mailhog'

Definition at line 18 of file class.tpl.app.mailhog.php.

◆ MENU_SERVICE

const TplAppMailhog::MENU_SERVICE = 'mailhogService'

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

◆ MENU_VERSIONS

const TplAppMailhog::MENU_VERSIONS = 'mailhogVersions'

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


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