From be80d74141efbeced112e3e64a6d4a9f2e1c6e52 Mon Sep 17 00:00:00 2001 From: Nico Verbruggen Date: Sun, 5 Dec 2021 14:31:49 +0100 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Cleanup=20and=20comments?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PHP Monitor.xcodeproj/project.pbxproj | 20 ++- phpmon/Domain/Core/Actions.swift | 14 +- phpmon/Domain/Core/App+ActivationPolicy.swift | 44 ++++++ phpmon/Domain/Core/App+GlobalHotkey.swift | 55 +++++++ phpmon/Domain/Core/App.swift | 138 +++++------------- .../Domain/Core/AppDelegate+MenuOutlets.swift | 40 +++++ phpmon/{ => Domain/Core}/AppDelegate.swift | 22 +-- phpmon/Domain/Core/Base.lproj/Main.storyboard | 20 +-- phpmon/Domain/PHP/ActivePhpInstallation.swift | 9 +- phpmon/Domain/PHP/PhpInstallation.swift | 7 +- phpmon/Domain/SiteList/SiteListCell.swift | 1 - phpmon/Domain/SiteList/SiteListVC.swift | 3 - phpmon/Domain/Terminal/Shell.swift | 2 +- 13 files changed, 230 insertions(+), 145 deletions(-) create mode 100644 phpmon/Domain/Core/App+ActivationPolicy.swift create mode 100644 phpmon/Domain/Core/App+GlobalHotkey.swift create mode 100644 phpmon/Domain/Core/AppDelegate+MenuOutlets.swift rename phpmon/{ => Domain/Core}/AppDelegate.swift (77%) diff --git a/PHP Monitor.xcodeproj/project.pbxproj b/PHP Monitor.xcodeproj/project.pbxproj index c1c21c4..b9a2dd5 100644 --- a/PHP Monitor.xcodeproj/project.pbxproj +++ b/PHP Monitor.xcodeproj/project.pbxproj @@ -59,6 +59,12 @@ C4AF9F7A2754499000D44ED0 /* Valet.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4AF9F792754499000D44ED0 /* Valet.swift */; }; C4AF9F7B2754499000D44ED0 /* Valet.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4AF9F792754499000D44ED0 /* Valet.swift */; }; C4AF9F7D275454A900D44ED0 /* ValetTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4AF9F7C275454A900D44ED0 /* ValetTest.swift */; }; + C4B97B75275CF08C003F3378 /* AppDelegate+MenuOutlets.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4B97B74275CF08C003F3378 /* AppDelegate+MenuOutlets.swift */; }; + C4B97B76275CF08C003F3378 /* AppDelegate+MenuOutlets.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4B97B74275CF08C003F3378 /* AppDelegate+MenuOutlets.swift */; }; + C4B97B78275CF1B5003F3378 /* App+ActivationPolicy.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4B97B77275CF1B5003F3378 /* App+ActivationPolicy.swift */; }; + C4B97B79275CF1B5003F3378 /* App+ActivationPolicy.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4B97B77275CF1B5003F3378 /* App+ActivationPolicy.swift */; }; + C4B97B7B275CF20A003F3378 /* App+GlobalHotkey.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4B97B7A275CF20A003F3378 /* App+GlobalHotkey.swift */; }; + C4B97B7C275CF20A003F3378 /* App+GlobalHotkey.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4B97B7A275CF20A003F3378 /* App+GlobalHotkey.swift */; }; C4CCBA6C275C567B008C7055 /* PMWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4CCBA6B275C567B008C7055 /* PMWindowController.swift */; }; C4CCBA6D275C567B008C7055 /* PMWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4CCBA6B275C567B008C7055 /* PMWindowController.swift */; }; C4D8016622B1584700C6DA1B /* Startup.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4D8016522B1584700C6DA1B /* Startup.swift */; }; @@ -150,6 +156,9 @@ C4AF9F76275447F100D44ED0 /* ValetConfigParserTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ValetConfigParserTest.swift; sourceTree = ""; }; C4AF9F792754499000D44ED0 /* Valet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Valet.swift; sourceTree = ""; }; C4AF9F7C275454A900D44ED0 /* ValetTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ValetTest.swift; sourceTree = ""; }; + C4B97B74275CF08C003F3378 /* AppDelegate+MenuOutlets.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AppDelegate+MenuOutlets.swift"; sourceTree = ""; }; + C4B97B77275CF1B5003F3378 /* App+ActivationPolicy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "App+ActivationPolicy.swift"; sourceTree = ""; }; + C4B97B7A275CF20A003F3378 /* App+GlobalHotkey.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "App+GlobalHotkey.swift"; sourceTree = ""; }; C4CCBA6B275C567B008C7055 /* PMWindowController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PMWindowController.swift; sourceTree = ""; }; C4D8016522B1584700C6DA1B /* Startup.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Startup.swift; sourceTree = ""; }; C4E713562570150F00007428 /* SECURITY.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = SECURITY.md; sourceTree = ""; }; @@ -242,7 +251,6 @@ C41C1B3522B0097F00E7CF16 /* phpmon */ = { isa = PBXGroup; children = ( - C41C1B3622B0097F00E7CF16 /* AppDelegate.swift */, C4EE188322D3386B00E126E5 /* Constants.swift */, C41E181722CB61EB0072CF09 /* Domain */, C41C1B3F22B0098000E7CF16 /* Info.plist */, @@ -342,8 +350,12 @@ C4B13B1D25C4915000548C3A /* Core */ = { isa = PBXGroup; children = ( + C41C1B3622B0097F00E7CF16 /* AppDelegate.swift */, + C4B97B74275CF08C003F3378 /* AppDelegate+MenuOutlets.swift */, C41C1B3C22B0098000E7CF16 /* Main.storyboard */, C4811D2322D70A4700B5F6B3 /* App.swift */, + C4B97B77275CF1B5003F3378 /* App+ActivationPolicy.swift */, + C4B97B7A275CF20A003F3378 /* App+GlobalHotkey.swift */, C4D8016522B1584700C6DA1B /* Startup.swift */, C41C1B4C22B0215A00E7CF16 /* Actions.swift */, ); @@ -519,6 +531,7 @@ C4CCBA6C275C567B008C7055 /* PMWindowController.swift in Sources */, C41CD0292628D8EE0065BBED /* GlobalKeybindPreference.swift in Sources */, C42295DD2358D02000E263B2 /* Command.swift in Sources */, + C4B97B78275CF1B5003F3378 /* App+ActivationPolicy.swift in Sources */, C4811D2422D70A4700B5F6B3 /* App.swift in Sources */, C41C1B4922B00A9800E7CF16 /* MenuBarImageGenerator.swift in Sources */, 5420395F2613607600FB00FA /* Preferences.swift in Sources */, @@ -530,11 +543,13 @@ C464ADAF275A7A69003FCD53 /* SiteListVC.swift in Sources */, C41C1B4B22B019FF00E7CF16 /* ActivePhpInstallation.swift in Sources */, C49EAB46259FC305007F6C3B /* Paths.swift in Sources */, + C4B97B7B275CF20A003F3378 /* App+GlobalHotkey.swift in Sources */, C476FF9822B0DD830098105B /* Alert.swift in Sources */, C474B00624C0E98C00066A22 /* LocalNotification.swift in Sources */, C48D0C9625CC80B100CC7490 /* HeaderView.swift in Sources */, C47331A2247093B7009A0597 /* StatusMenu.swift in Sources */, C46FA23F246C358E00944F05 /* StringExtension.swift in Sources */, + C4B97B75275CF08C003F3378 /* AppDelegate+MenuOutlets.swift in Sources */, C464ADAC275A7A3F003FCD53 /* SiteListWC.swift in Sources */, C464ADB2275A87CA003FCD53 /* SiteListCell.swift in Sources */, C4EE188422D3386B00E126E5 /* Constants.swift in Sources */, @@ -561,10 +576,13 @@ C4F780AE25D80B37000DBC97 /* ExtensionParserTest.swift in Sources */, C4F780C725D80B75000DBC97 /* StatusMenu.swift in Sources */, C42759682627662800093CAE /* NSMenuExtension.swift in Sources */, + C4B97B76275CF08C003F3378 /* AppDelegate+MenuOutlets.swift in Sources */, C4F780CD25D80B75000DBC97 /* Alert.swift in Sources */, C481F79726164A78004FBCFF /* PrefsVC.swift in Sources */, C464ADB3275A87CA003FCD53 /* SiteListCell.swift in Sources */, C4AF9F78275447F100D44ED0 /* ValetConfigParserTest.swift in Sources */, + C4B97B7C275CF20A003F3378 /* App+GlobalHotkey.swift in Sources */, + C4B97B79275CF1B5003F3378 /* App+ActivationPolicy.swift in Sources */, C4F7809C25D80344000DBC97 /* CommandTest.swift in Sources */, C4F780BA25D80B62000DBC97 /* AppDelegate.swift in Sources */, C4998F0B2617633900B2526E /* PrefsWC.swift in Sources */, diff --git a/phpmon/Domain/Core/Actions.swift b/phpmon/Domain/Core/Actions.swift index 244400f..f5832e0 100644 --- a/phpmon/Domain/Core/Actions.swift +++ b/phpmon/Domain/Core/Actions.swift @@ -191,9 +191,14 @@ class Actions { // MARK: - Quick Fix /** - Detects all currently available PHP versions, and unlinks each and every one of them. - After this, the brew services are also stopped, the latest PHP version is linked, and php + nginx are restarted. - If this does not solve the issue, the user may need to install additional extensions and/or run `composer global update`. + Detects all currently available PHP versions, + and unlinks each and every one of them. + + After this, the brew services are also stopped, + the latest PHP version is linked, and php + nginx are restarted. + + If this does not solve the issue, the user may need to install additional + extensions and/or run `composer global update`. */ public static func fixMyPhp() { @@ -241,7 +246,8 @@ class Actions { let e_original = original.replacingOccurrences(of: "/", with: "\\/") let e_replacement = replacement.replacingOccurrences(of: "/", with: "\\/") - // Check if gsed exists; it is able to follow symlinks, which we want to do to toggle the extension + // Check if gsed exists; it is able to follow symlinks, + // which we want to do to toggle the extension if Shell.fileExists("\(Paths.binPath)/gsed") { Shell.run("\(Paths.binPath)/gsed -i --follow-symlinks 's/\(e_original)/\(e_replacement)/g' \(file)") } else { diff --git a/phpmon/Domain/Core/App+ActivationPolicy.swift b/phpmon/Domain/Core/App+ActivationPolicy.swift new file mode 100644 index 0000000..f031301 --- /dev/null +++ b/phpmon/Domain/Core/App+ActivationPolicy.swift @@ -0,0 +1,44 @@ +// +// App+ActivationPolicy.swift +// PHP Monitor +// +// Created by Nico Verbruggen on 05/12/2021. +// Copyright © 2021 Nico Verbruggen. All rights reserved. +// + +import Cocoa +import Foundation + +extension App { + + // MARK: - Application State + + /** + Registers a window as currently open. + */ + public func register(window name: String) { + if !openWindows.contains(name) { + openWindows.append(name) + } + updateActivationPolicy() + } + + /** + Removes a window, assuming it was closed. + */ + public func remove(window name: String) { + openWindows.removeAll { window in + window == name + } + updateActivationPolicy() + } + + /** + If there are any open windows, the app will be a regular app. + If there are no windows open, the app will be an accessory (toolbar) app. + */ + public func updateActivationPolicy() { + NSApp.setActivationPolicy(openWindows.count > 0 ? .regular : .accessory) + } + +} diff --git a/phpmon/Domain/Core/App+GlobalHotkey.swift b/phpmon/Domain/Core/App+GlobalHotkey.swift new file mode 100644 index 0000000..3b6addb --- /dev/null +++ b/phpmon/Domain/Core/App+GlobalHotkey.swift @@ -0,0 +1,55 @@ +// +// App+GlobalHotkey.swift +// PHP Monitor +// +// Created by Nico Verbruggen on 05/12/2021. +// Copyright © 2021 Nico Verbruggen. All rights reserved. +// + +import HotKey +import Cocoa + +extension App { + + // MARK: - Methods + + /** + On startup, the preferences should be loaded from the .plist, + and we'll enable the shortcut if it is set. + */ + func loadGlobalHotkey() { + // Make sure we can retrieve the hotkey from preferences + guard let hotkey = Preferences.preferences[.globalHotkey] as? String else { + print("No global hotkey loaded") + return + } + + // Make sure we can parse the JSON into the desired format + guard let keybindPref = GlobalKeybindPreference.fromJson(hotkey) else { + print("No global hotkey loaded, could not be parsed!") + self.shortcutHotkey = nil + return + } + + self.shortcutHotkey = HotKey(keyCombo: KeyCombo( + carbonKeyCode: keybindPref.keyCode, + carbonModifiers: keybindPref.carbonFlags + )) + } + + /** + Sets up the action that needs to occur when the shortcut key is pressed + (opens the menu). + */ + func setupGlobalHotkeyListener() { + guard let hotkey = self.shortcutHotkey else { + return + } + + hotkey.keyDownHandler = { + MainMenu.shared.statusItem.button?.performClick(nil) + NSApplication.shared.activate(ignoringOtherApps: true) + } + } + +} diff --git a/phpmon/Domain/Core/App.swift b/phpmon/Domain/Core/App.swift index 035b0ff..b3786f0 100644 --- a/phpmon/Domain/Core/App.swift +++ b/phpmon/Domain/Core/App.swift @@ -10,10 +10,16 @@ import HotKey class App { + // MARK: Static Vars + + /** The static app instance. Accessible at any time. */ static let shared = App() - init() { - loadGlobalHotkey() + /** Retrieve the version number from the main info dictionary, Info.plist. */ + static var version: String { + let version = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as! String + let build = Bundle.main.infoDictionary?["CFBundleVersion"] as! String + return "\(version) (\(build))" } /** Information about the currently linked PHP installation. */ @@ -26,62 +32,46 @@ class App { return App.shared.busy } + // MARK: - Initializer + + /** When the app boots up, this code will run even before the start-up checks. */ + init() { + loadGlobalHotkey() + } + + // MARK: Variables + /** The list of preferences that are currently active. */ var preferences: [PreferenceName: Bool]! - /** - The window controller of the currently active preferences window. - */ + /** The window controller of the currently active preferences window. */ var preferencesWindowController: PrefsWC? = nil - /** - The window controller of the currently active site list window. - */ + /** The window controller of the currently active site list window. */ var siteListWindowController: SiteListWC? = nil - /** - Whether the application is busy switching versions. - */ + /** Whether the application is busy switching versions. */ var busy: Bool = false - /** - The currently active installation of PHP. - */ + /** The currently active installation of PHP. */ var currentInstall: ActivePhpInstallation? = nil - /** - All available versions of PHP. - */ + /** All available versions of PHP. */ var availablePhpVersions : [String] = [] - /** - Cached information about the PHP installations; contains only the full version number at this point. - */ + /** Cached information about the PHP installations. */ var cachedPhpInstallations : [String: PhpInstallation] = [:] - /** - The timer that will periodically fetch the PHP version that is currently active. - */ + /** Timer that will periodically reload info about the user's PHP installation. */ var timer: Timer? - /** - Information we were able to discern from the Homebrew info command (as JSON). - */ + /** Information we were able to discern from the Homebrew info command (as JSON). */ var brewPhpPackage: HomebrewPackage! = nil { didSet { brewPhpVersion = brewPhpPackage!.version } } - /** - Retrieve the version number from the main info dictionary, Info.plist. - */ - static var version: String { - let version = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as! String - let build = Bundle.main.infoDictionary?["CFBundleVersion"] as! String - return "\(version) (\(build))" - } - /** The version that the `php` formula via Brew is aliased to on the current system. @@ -93,6 +83,8 @@ class App { */ var brewPhpVersion: String = Constants.LatestStablePhpVersion + // MARK: - Global Hotkey + /** The shortcut the user has requested. */ @@ -102,80 +94,16 @@ class App { } } - // MARK: - Methods + // MARK: - Activation Policy /** - On startup, the preferences should be loaded from the .plist, and we'll enable the shortcut if it is set. - */ - private func loadGlobalHotkey() { - // Make sure we can retrieve the hotkey from preferences; if we cannot, no hotkey is set - guard let hotkey = Preferences.preferences[.globalHotkey] as? String else { - print("No global hotkey loaded") - return - } - - // Make sure we can parse the JSON into the desired format; if we cannot, no hotkey is set - guard let keybindPref = GlobalKeybindPreference.fromJson(hotkey) else { - print("No global hotkey loaded, could not be parsed!") - self.shortcutHotkey = nil - return - } - - self.shortcutHotkey = HotKey(keyCombo: KeyCombo( - carbonKeyCode: keybindPref.keyCode, - carbonModifiers: keybindPref.carbonFlags - )) - } - - /** - Sets up the action that needs to occur when the shortcut key is pressed (open the menu). - */ - private func setupGlobalHotkeyListener() { - guard let hotkey = self.shortcutHotkey else { - return - } - - hotkey.keyDownHandler = { - MainMenu.shared.statusItem.button?.performClick(nil) - NSApplication.shared.activate(ignoringOtherApps: true) - } - } - - // MARK: - Application State - - /** - Keep track of open windows. + Variable that keeps track of which windows are currently open. + (Please note that window controllers remain open in memory once opened.) + When this list is updated, the app activation policy is re-evaluated. - The app activation policy dictates how the app runs (as a normal app or as a toolbar app). + The app activation policy dictates how the app runs + (as a normal app or as a toolbar app). */ var openWindows: [String] = [] - /** - Registers a window as currently open. - */ - public func register(window name: String) { - if !openWindows.contains(name) { - openWindows.append(name) - } - updateActivationPolicy() - } - - /** - Removes a window, assuming it was closed. - */ - public func remove(window name: String) { - openWindows.removeAll { window in - window == name - } - updateActivationPolicy() - } - - /** - If there are any open windows, the app will be a regular app. - If there are no windows open, the app will be an accessory (toolbar) app. - */ - public func updateActivationPolicy() { - NSApp.setActivationPolicy(openWindows.count > 0 ? .regular : .accessory) - } - } diff --git a/phpmon/Domain/Core/AppDelegate+MenuOutlets.swift b/phpmon/Domain/Core/AppDelegate+MenuOutlets.swift new file mode 100644 index 0000000..3d13d92 --- /dev/null +++ b/phpmon/Domain/Core/AppDelegate+MenuOutlets.swift @@ -0,0 +1,40 @@ +// +// AppDelegate+MenuOutlets.swift +// PHP Monitor +// +// Created by Nico Verbruggen on 05/12/2021. +// Copyright © 2021 Nico Verbruggen. All rights reserved. +// + +import Foundation + +/** + Any outlets connected to the app's main menu (not the menu that shows when the icon in + the menu bar is clicked, but the regular app's main menu) are configured here. + + Default interactions like copy/paste, select all, close window etc. are wired up by + default in the storyboard and do not need to be manually added. + + Extra functionality (like the menu item to reload the list of sites) does, however. + + - Note: This menu is only displayed when the app is NOT running in accessory mode. + For more information about this, please see the ActivationPolicy-related extension. + */ +extension AppDelegate { + + // MARK: - Menu Interactions + + @IBAction func reloadSiteListPressed(_ sender: Any) { + let vc = App.shared.siteListWindowController? + .window?.contentViewController as? SiteListVC + + if vc != nil { + // If the view exists, directly reload the list of sites + vc!.reloadSites() + } else { + // If the view does not exist, reload the cached data that was populated when the app initially launched. + Valet.shared.reloadSites() + } + } + +} diff --git a/phpmon/AppDelegate.swift b/phpmon/Domain/Core/AppDelegate.swift similarity index 77% rename from phpmon/AppDelegate.swift rename to phpmon/Domain/Core/AppDelegate.swift index e78f753..c91b718 100644 --- a/phpmon/AppDelegate.swift +++ b/phpmon/Domain/Core/AppDelegate.swift @@ -39,7 +39,8 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele let paths: Paths /** - The Valet singleton that determines all information about Valet and its current configuration. + The Valet singleton that determines all information + about Valet and its current configuration. */ let valet: Valet @@ -74,17 +75,16 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele self.menu.startup() } - func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) { + /** + Ensure that the application displays notifications even when the app is active. + */ + func userNotificationCenter( + _ center: UNUserNotificationCenter, + willPresent notification: UNNotification, + withCompletionHandler completionHandler: + @escaping (UNNotificationPresentationOptions) -> Void + ) { completionHandler([.banner]) } - // MARK: - Menu Interactions - - @IBAction func reloadSiteListPressed(_ sender: Any) { - let vc = App.shared.siteListWindowController?.window?.contentViewController as? SiteListVC - if vc != nil { - vc!.reloadSites() - } - } - } diff --git a/phpmon/Domain/Core/Base.lproj/Main.storyboard b/phpmon/Domain/Core/Base.lproj/Main.storyboard index 04fcab6..6c9f733 100644 --- a/phpmon/Domain/Core/Base.lproj/Main.storyboard +++ b/phpmon/Domain/Core/Base.lproj/Main.storyboard @@ -590,13 +590,13 @@ Gw - + - + - + @@ -664,15 +664,6 @@ Gw - @@ -705,7 +696,6 @@ Gw - @@ -724,7 +714,7 @@ Gw - + diff --git a/phpmon/Domain/PHP/ActivePhpInstallation.swift b/phpmon/Domain/PHP/ActivePhpInstallation.swift index 81dd40b..a638057 100644 --- a/phpmon/Domain/PHP/ActivePhpInstallation.swift +++ b/phpmon/Domain/PHP/ActivePhpInstallation.swift @@ -13,7 +13,8 @@ import Foundation When initialized, that version's .ini files are also scanned (for active or inactive extensions). Integrity checks can be performed to determine whether PHP-FPM is configured correctly. - - Note: Each installation has a separate version number. Using `version.short` is advisable if you want to interact with Homebrew. + - Note: Each installation has a separate version number. + Using `version.short` is advisable if you want to interact with Homebrew. */ class ActivePhpInstallation { @@ -100,8 +101,10 @@ class ActivePhpInstallation { * 10000: an integer = amount of bytes * 1K, 1M, 1G = shorthand for kilobytes, megabytes and gigabytes - If none of these notations are used, the _fallback_ value is used. We'll show an emoji to indicate something has gone wrong here. - To clarify, B gets appended to valid values. As a result, "5M" (valid) becomes "5MB", and "5MB" (invalid) becomes ⚠️. + If none of these notations are used, the _fallback_ value is used. + We'll show an emoji to indicate something has gone wrong here. + To clarify, B gets appended to valid values. + As a result, "5M" (valid) becomes "5MB", and "5MB" (invalid) becomes ⚠️. - Parameter key: The key of the `ini` value that needs to be retrieved. For example, you can use `memory_limit`. */ diff --git a/phpmon/Domain/PHP/PhpInstallation.swift b/phpmon/Domain/PHP/PhpInstallation.swift index 11e513f..bf9b2f8 100644 --- a/phpmon/Domain/PHP/PhpInstallation.swift +++ b/phpmon/Domain/PHP/PhpInstallation.swift @@ -1,5 +1,5 @@ // -// BrewPhpInstallation.swift +// PhpInstallation.swift // PHP Monitor // // Created by Nico Verbruggen on 28/11/2021. @@ -13,6 +13,11 @@ class PhpInstallation { var longVersion: String var homebrewInfo: HomebrewPackage + /** + In order to determine details about a PHP installation, we’ll simply run `php-config --version` + in the relevant directory, and we’ll also attempt to determine information about the Homebrew + formula for that particular installation. + */ init(_ version: String) { let phpConfigExecutablePath = "\(Paths.optPath)/php@\(version)/bin/php-config" self.longVersion = version diff --git a/phpmon/Domain/SiteList/SiteListCell.swift b/phpmon/Domain/SiteList/SiteListCell.swift index c514b80..827e0ab 100644 --- a/phpmon/Domain/SiteList/SiteListCell.swift +++ b/phpmon/Domain/SiteList/SiteListCell.swift @@ -18,7 +18,6 @@ class SiteListCell: NSTableCellView @IBOutlet weak var imageViewType: NSImageView! @IBOutlet weak var labelDriver: NSTextField! - @IBOutlet weak var labelPhpVersion: NSTextField! override func draw(_ dirtyRect: NSRect) { super.draw(dirtyRect) diff --git a/phpmon/Domain/SiteList/SiteListVC.swift b/phpmon/Domain/SiteList/SiteListVC.swift index 40c01a6..d20d4e7 100644 --- a/phpmon/Domain/SiteList/SiteListVC.swift +++ b/phpmon/Domain/SiteList/SiteListVC.swift @@ -128,9 +128,6 @@ class SiteListVC: NSViewController, NSTableViewDelegate, NSTableViewDataSource { /// Show the current driver userCell.labelDriver.stringValue = item.driver - /// TODO: Load the correct PHP version (not determined as of yet) - userCell.labelPhpVersion.stringValue = "PHP 8.0" - return userCell } diff --git a/phpmon/Domain/Terminal/Shell.swift b/phpmon/Domain/Terminal/Shell.swift index 379e48d..a1df115 100644 --- a/phpmon/Domain/Terminal/Shell.swift +++ b/phpmon/Domain/Terminal/Shell.swift @@ -62,7 +62,7 @@ class Shell { requiresPath: Bool = false ) { // Equivalent of piping to /dev/null; don't do anything with the string - _ = Shell.pipe(command) + _ = Shell.pipe(command, requiresPath: requiresPath) } /**