mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-12-23 20:00:05 +01:00
♻️ PHP Guard changes
This commit is contained in:
@@ -9,6 +9,7 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
import Cocoa
|
import Cocoa
|
||||||
|
|
||||||
|
@MainActor
|
||||||
class BetterAlert {
|
class BetterAlert {
|
||||||
|
|
||||||
var windowController: NSWindowController!
|
var windowController: NSWindowController!
|
||||||
|
|||||||
@@ -142,17 +142,27 @@ class Stats {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static func evaluateLastLinkedPhpVersion() {
|
public static func evaluateLastLinkedPhpVersion() {
|
||||||
let currentVersion = PhpEnv.phpInstall.version.short
|
let currentVersion = PhpEnv.phpInstall.version?.short ?? ""
|
||||||
let previousVersion = Stats.lastGlobalPhpVersion
|
let previousVersion = Stats.lastGlobalPhpVersion
|
||||||
|
|
||||||
// Save the PHP version that is currently in use (only if unknown)
|
if currentVersion == "" {
|
||||||
if Stats.lastGlobalPhpVersion == "" {
|
return Log.warn("<PG> PHP Guard is unable to determine the current PHP version!")
|
||||||
|
}
|
||||||
|
Log.info("<PG> The currently linked version of PHP is: \(currentVersion).")
|
||||||
|
|
||||||
|
if previousVersion == "" {
|
||||||
Stats.persistCurrentGlobalPhpVersion(version: currentVersion)
|
Stats.persistCurrentGlobalPhpVersion(version: currentVersion)
|
||||||
Log.info("Persisting the currently linked PHP version (first time only).")
|
return Log.warn("<PG> PHP Guard is saving the currently linked PHP version (first time only).")
|
||||||
} else {
|
}
|
||||||
Log.info("Previously, the globally linked PHP version was: \(previousVersion).")
|
Log.info("<PG> Previously, the globally linked PHP version was: \(previousVersion).")
|
||||||
if previousVersion != currentVersion {
|
|
||||||
Log.info("Currently, that version is: \(currentVersion). This is a mismatch.")
|
if previousVersion == currentVersion {
|
||||||
|
return Log.info("<PG> PHP Guard did not notice any changes in the linked PHP version.")
|
||||||
|
}
|
||||||
|
|
||||||
|
// At this point, the version is *not* a match
|
||||||
|
Log.info("<PG> PHP Guard noticed a different PHP version. An alert will be displayed!")
|
||||||
|
|
||||||
Task { @MainActor in
|
Task { @MainActor in
|
||||||
BetterAlert()
|
BetterAlert()
|
||||||
.withInformation(
|
.withInformation(
|
||||||
@@ -179,5 +189,3 @@ class Stats {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user