mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2026-03-29 16:10:08 +02:00
👌 All methods are internal by default
This commit is contained in:
@@ -19,7 +19,7 @@ class Startup {
|
|||||||
- Parameter success: Callback that is fired if the application can proceed with launch
|
- Parameter success: Callback that is fired if the application can proceed with launch
|
||||||
- Parameter failure: Callback that is fired if the application must retry launch
|
- Parameter failure: Callback that is fired if the application must retry launch
|
||||||
*/
|
*/
|
||||||
public func checkEnvironment(success: () -> Void, failure: @escaping () -> Void)
|
func checkEnvironment(success: () -> Void, failure: @escaping () -> Void)
|
||||||
{
|
{
|
||||||
self.failureCallback = failure
|
self.failureCallback = failure
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ struct HomebrewPackage : Decodable {
|
|||||||
let full_name: String
|
let full_name: String
|
||||||
let aliases: [String]
|
let aliases: [String]
|
||||||
|
|
||||||
public func getVersion() -> String {
|
public var version: String {
|
||||||
return aliases.first!.replacingOccurrences(of: "php@", with: "")
|
return aliases.first!.replacingOccurrences(of: "php@", with: "")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ class PhpExtension {
|
|||||||
/**
|
/**
|
||||||
This simply toggles the extension in the .ini file. You may need to restart the other services in order for this change to apply.
|
This simply toggles the extension in the .ini file. You may need to restart the other services in order for this change to apply.
|
||||||
*/
|
*/
|
||||||
public func toggle() {
|
func toggle() {
|
||||||
Actions.sed(
|
Actions.sed(
|
||||||
file: self.file,
|
file: self.file,
|
||||||
original: self.line,
|
original: self.line,
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
import Cocoa
|
import Cocoa
|
||||||
|
|
||||||
class StatusMenu : NSMenu {
|
class StatusMenu : NSMenu {
|
||||||
public func addPhpVersionMenuItems() {
|
func addPhpVersionMenuItems() {
|
||||||
if App.shared.currentInstall == nil {
|
if App.shared.currentInstall == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -24,7 +24,7 @@ class StatusMenu : NSMenu {
|
|||||||
self.addItem(HeaderView.asMenuItem(text: phpVersionText))
|
self.addItem(HeaderView.asMenuItem(text: phpVersionText))
|
||||||
}
|
}
|
||||||
|
|
||||||
public func addPhpActionMenuItems() {
|
func addPhpActionMenuItems() {
|
||||||
if App.busy {
|
if App.busy {
|
||||||
self.addItem(NSMenuItem(title: "mi_busy".localized, action: nil, keyEquivalent: ""))
|
self.addItem(NSMenuItem(title: "mi_busy".localized, action: nil, keyEquivalent: ""))
|
||||||
return
|
return
|
||||||
@@ -73,7 +73,7 @@ class StatusMenu : NSMenu {
|
|||||||
self.addItem(NSMenuItem(title: "mi_restart_all_services".localized, action: #selector(MainMenu.restartAllServices), keyEquivalent: "s"))
|
self.addItem(NSMenuItem(title: "mi_restart_all_services".localized, action: #selector(MainMenu.restartAllServices), keyEquivalent: "s"))
|
||||||
}
|
}
|
||||||
|
|
||||||
public func addPhpConfigurationMenuItems() {
|
func addPhpConfigurationMenuItems() {
|
||||||
if App.shared.currentInstall == nil {
|
if App.shared.currentInstall == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ class App {
|
|||||||
*/
|
*/
|
||||||
var brewPhpPackage: HomebrewPackage? = nil {
|
var brewPhpPackage: HomebrewPackage? = nil {
|
||||||
didSet {
|
didSet {
|
||||||
self.brewPhpVersion = self.brewPhpPackage!.getVersion()
|
self.brewPhpVersion = self.brewPhpPackage!.version
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ class MainMenu: NSObject, NSWindowDelegate {
|
|||||||
/**
|
/**
|
||||||
Kick off the startup of the rendering of the main menu.
|
Kick off the startup of the rendering of the main menu.
|
||||||
*/
|
*/
|
||||||
public func startup() {
|
func startup() {
|
||||||
// Start with the icon
|
// Start with the icon
|
||||||
self.setStatusBar(image: NSImage(named: NSImage.Name("StatusBarIcon"))!)
|
self.setStatusBar(image: NSImage(named: NSImage.Name("StatusBarIcon"))!)
|
||||||
// Perform environment boot checks
|
// Perform environment boot checks
|
||||||
@@ -75,7 +75,7 @@ class MainMenu: NSObject, NSWindowDelegate {
|
|||||||
/**
|
/**
|
||||||
Update the menu's contents, based on what's going on.
|
Update the menu's contents, based on what's going on.
|
||||||
*/
|
*/
|
||||||
public func update() {
|
func update() {
|
||||||
// Update the menu item on the main thread
|
// Update the menu item on the main thread
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
// Create a new menu
|
// Create a new menu
|
||||||
@@ -176,13 +176,13 @@ class MainMenu: NSObject, NSWindowDelegate {
|
|||||||
|
|
||||||
// MARK: - Actions
|
// MARK: - Actions
|
||||||
|
|
||||||
@objc public func restartPhpFpm() {
|
@objc func restartPhpFpm() {
|
||||||
self.waitAndExecute({
|
self.waitAndExecute({
|
||||||
Actions.restartPhpFpm()
|
Actions.restartPhpFpm()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc public func restartAllServices() {
|
@objc func restartAllServices() {
|
||||||
self.waitAndExecute({
|
self.waitAndExecute({
|
||||||
Actions.restartDnsMasq()
|
Actions.restartDnsMasq()
|
||||||
Actions.restartPhpFpm()
|
Actions.restartPhpFpm()
|
||||||
@@ -190,19 +190,19 @@ class MainMenu: NSObject, NSWindowDelegate {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc public func restartNginx() {
|
@objc func restartNginx() {
|
||||||
self.waitAndExecute({
|
self.waitAndExecute({
|
||||||
Actions.restartNginx()
|
Actions.restartNginx()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc public func restartDnsMasq() {
|
@objc func restartDnsMasq() {
|
||||||
self.waitAndExecute({
|
self.waitAndExecute({
|
||||||
Actions.restartDnsMasq()
|
Actions.restartDnsMasq()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc public func toggleExtension(sender: ExtensionMenuItem) {
|
@objc func toggleExtension(sender: ExtensionMenuItem) {
|
||||||
self.waitAndExecute({
|
self.waitAndExecute({
|
||||||
// Toggle that extension
|
// Toggle that extension
|
||||||
print("Toggling extension '\(sender.phpExtension!.name)'")
|
print("Toggling extension '\(sender.phpExtension!.name)'")
|
||||||
@@ -210,7 +210,7 @@ class MainMenu: NSObject, NSWindowDelegate {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc public func openPhpInfo() {
|
@objc func openPhpInfo() {
|
||||||
self.waitAndExecute({
|
self.waitAndExecute({
|
||||||
try! "<?php phpinfo();".write(toFile: "/tmp/phpmon_phpinfo.php", atomically: true, encoding: .utf8)
|
try! "<?php phpinfo();".write(toFile: "/tmp/phpmon_phpinfo.php", atomically: true, encoding: .utf8)
|
||||||
Shell.run("\(Paths.binPath)/php-cgi -q /tmp/phpmon_phpinfo.php > /tmp/phpmon_phpinfo.html")
|
Shell.run("\(Paths.binPath)/php-cgi -q /tmp/phpmon_phpinfo.php > /tmp/phpmon_phpinfo.html")
|
||||||
@@ -219,7 +219,7 @@ class MainMenu: NSObject, NSWindowDelegate {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc public func forceRestartLatestPhp() {
|
@objc func forceRestartLatestPhp() {
|
||||||
// Tell the user the switch is about to occur
|
// Tell the user the switch is about to occur
|
||||||
Alert.notify(message: "alert.force_reload.title".localized, info: "alert.force_reload.info".localized)
|
Alert.notify(message: "alert.force_reload.title".localized, info: "alert.force_reload.info".localized)
|
||||||
// Start switching
|
// Start switching
|
||||||
@@ -232,7 +232,7 @@ class MainMenu: NSObject, NSWindowDelegate {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc public func openActiveConfigFolder() {
|
@objc func openActiveConfigFolder() {
|
||||||
if (App.phpInstall!.version.error) {
|
if (App.phpInstall!.version.error) {
|
||||||
// php version was not identified
|
// php version was not identified
|
||||||
Actions.openGenericPhpConfigFolder()
|
Actions.openGenericPhpConfigFolder()
|
||||||
@@ -243,11 +243,11 @@ class MainMenu: NSObject, NSWindowDelegate {
|
|||||||
Actions.openPhpConfigFolder(version: App.phpInstall!.version.short)
|
Actions.openPhpConfigFolder(version: App.phpInstall!.version.short)
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc public func openValetConfigFolder() {
|
@objc func openValetConfigFolder() {
|
||||||
Actions.openValetConfigFolder()
|
Actions.openValetConfigFolder()
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc public func switchToPhpVersion(sender: PhpMenuItem) {
|
@objc func switchToPhpVersion(sender: PhpMenuItem) {
|
||||||
print("Switching to: PHP \(sender.version)")
|
print("Switching to: PHP \(sender.version)")
|
||||||
|
|
||||||
self.setBusyImage()
|
self.setBusyImage()
|
||||||
@@ -282,12 +282,12 @@ class MainMenu: NSObject, NSWindowDelegate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc public func openAbout() {
|
@objc func openAbout() {
|
||||||
NSApplication.shared.activate(ignoringOtherApps: true)
|
NSApplication.shared.activate(ignoringOtherApps: true)
|
||||||
NSApplication.shared.orderFrontStandardAboutPanel()
|
NSApplication.shared.orderFrontStandardAboutPanel()
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc public func terminateApp() {
|
@objc func terminateApp() {
|
||||||
NSApplication.shared.terminate(nil)
|
NSApplication.shared.terminate(nil)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ class Shell {
|
|||||||
|
|
||||||
- Parameter command: The command to run
|
- Parameter command: The command to run
|
||||||
*/
|
*/
|
||||||
public func run(_ command: String) {
|
func run(_ command: String) {
|
||||||
// Equivalent of piping to /dev/null; don't do anything with the string
|
// Equivalent of piping to /dev/null; don't do anything with the string
|
||||||
_ = self.pipe(command)
|
_ = self.pipe(command)
|
||||||
}
|
}
|
||||||
@@ -43,7 +43,7 @@ class Shell {
|
|||||||
- Parameter command: The command to run
|
- Parameter command: The command to run
|
||||||
- Parameter shell: Path to the shell to invoke
|
- Parameter shell: Path to the shell to invoke
|
||||||
*/
|
*/
|
||||||
public func pipe(_ command: String, shell: String = "/bin/sh") -> String {
|
func pipe(_ command: String, shell: String = "/bin/sh") -> String {
|
||||||
let task = Process()
|
let task = Process()
|
||||||
let pipe = Pipe()
|
let pipe = Pipe()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user