mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-08-08 04:20:07 +02:00
👌 Cleanup
This commit is contained in:
@ -74,6 +74,19 @@ class Actions {
|
|||||||
.appendingPathComponent(".config/valet")
|
.appendingPathComponent(".config/valet")
|
||||||
NSWorkspace.shared.activateFileViewerSelecting([file] as [URL])
|
NSWorkspace.shared.activateFileViewerSelecting([file] as [URL])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: - Other Actions
|
||||||
|
|
||||||
|
public static func createTempPhpInfoFile() -> URL
|
||||||
|
{
|
||||||
|
// Write a file called `phpmon_phpinfo.php` to /tmp
|
||||||
|
try! "<?php phpinfo();".write(toFile: "/tmp/phpmon_phpinfo.php", atomically: true, encoding: .utf8)
|
||||||
|
|
||||||
|
// Tell php-cgi to run the PHP and output as an .html file
|
||||||
|
Shell.run("\(Paths.binPath)/php-cgi -q /tmp/phpmon_phpinfo.php > /tmp/phpmon_phpinfo.html")
|
||||||
|
|
||||||
|
return URL(string: "file:///private/tmp/phpmon_phpinfo.html")!
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - Quick Fix
|
// MARK: - Quick Fix
|
||||||
|
|
||||||
|
@ -307,34 +307,38 @@ class MainMenu: NSObject, NSWindowDelegate, NSMenuDelegate {
|
|||||||
waitAndExecute {
|
waitAndExecute {
|
||||||
sender.phpExtension?.toggle()
|
sender.phpExtension?.toggle()
|
||||||
|
|
||||||
if Preferences.preferences[.autoServiceRestartAfterExtensionToggle] as! Bool == true {
|
if Preferences.isTrue(.autoServiceRestartAfterExtensionToggle) {
|
||||||
Actions.restartPhpFpm()
|
Actions.restartPhpFpm()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc func openPhpInfo() {
|
@objc func openPhpInfo() {
|
||||||
|
var url: URL? = nil
|
||||||
|
|
||||||
waitAndExecute {
|
waitAndExecute {
|
||||||
// Write a file called `phpmon_phpinfo.php` to /tmp
|
url = Actions.createTempPhpInfoFile()
|
||||||
try! "<?php phpinfo();".write(toFile: "/tmp/phpmon_phpinfo.php", atomically: true, encoding: .utf8)
|
|
||||||
|
|
||||||
// Tell php-cgi to run the PHP and output as an .html file
|
|
||||||
Shell.run("\(Paths.binPath)/php-cgi -q /tmp/phpmon_phpinfo.php > /tmp/phpmon_phpinfo.html")
|
|
||||||
} completion: {
|
} completion: {
|
||||||
// When this has been completed, open the URL to the file in the browser
|
// When this has been completed, open the URL to the file in the browser
|
||||||
NSWorkspace.shared.open(URL(string: "file:///private/tmp/phpmon_phpinfo.html")!)
|
NSWorkspace.shared.open(url!)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc 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
|
||||||
waitAndExecute {
|
waitAndExecute {
|
||||||
Actions.fixMyPhp()
|
Actions.fixMyPhp()
|
||||||
} completion: {
|
} completion: {
|
||||||
Alert.notify(message: "alert.force_reload_done.title".localized, info: "alert.force_reload_done.info".localized)
|
Alert.notify(
|
||||||
|
message: "alert.force_reload_done.title".localized,
|
||||||
|
info: "alert.force_reload_done.info".localized
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -468,10 +472,8 @@ class MainMenu: NSObject, NSWindowDelegate, NSMenuDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Run composer updates
|
// Run composer updates
|
||||||
if Preferences.preferences[.autoComposerGlobalUpdateAfterSwitch] as! Bool == true {
|
if Preferences.isTrue(.autoComposerGlobalUpdateAfterSwitch) {
|
||||||
self.updateGlobalDependencies(notify: false, completion: { success in
|
self.updateGlobalDependencies(notify: false, completion: { _ in sendLocalNotification() })
|
||||||
sendLocalNotification()
|
|
||||||
})
|
|
||||||
} else {
|
} else {
|
||||||
sendLocalNotification()
|
sendLocalNotification()
|
||||||
}
|
}
|
||||||
|
@ -66,6 +66,10 @@ class Preferences {
|
|||||||
return Self.shared.cachedPreferences
|
return Self.shared.cachedPreferences
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static func isTrue(_ preference: PreferenceName) -> Bool {
|
||||||
|
return Preferences.preferences[preference] as! Bool == true
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - Internal Functionality
|
// MARK: - Internal Functionality
|
||||||
|
|
||||||
static func cache() -> [PreferenceName: Any] {
|
static func cache() -> [PreferenceName: Any] {
|
||||||
|
@ -21,8 +21,7 @@ class CheckboxPreferenceView: NSView, XibLoadable {
|
|||||||
|
|
||||||
var preference: PreferenceName! {
|
var preference: PreferenceName! {
|
||||||
didSet {
|
didSet {
|
||||||
let shouldDisplay = Preferences.preferences[self.preference] as! Bool == true
|
self.buttonCheckbox.state = Preferences.isTrue(self.preference) ? .on : .off
|
||||||
self.buttonCheckbox.state = shouldDisplay ? .on : .off
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user