1
0
mirror of https://github.com/nicoverbruggen/phpmon.git synced 2025-11-07 05:10:06 +01:00

🏗 WIP: Interactions

This commit is contained in:
2022-12-06 20:53:42 +01:00
parent 31a0bb986f
commit 073b7cf943
5 changed files with 12 additions and 41 deletions

View File

@@ -1,21 +0,0 @@
//
// ValetInteractable.swift
// PHP Monitor
//
// Created by Nico Verbruggen on 21/10/2022.
// Copyright © 2022 Nico Verbruggen. All rights reserved.
//
import Foundation
protocol ValetInteractable {
func secure() async throws
func unsecure() async throws
func isolate(version: PhpVersionNumber) async throws
func unlink() async throws
}

View File

@@ -10,11 +10,11 @@ import Foundation
#warning("ValetInteractor needs to be implemented and used")
class ValetInteractor {
public static func secure(site: ValetSite) async throws {
public static func toggleSecure(site: ValetSite) async throws {
// TODO
}
public static func unsecure(site: ValetSite) async throws {
public static func toggleSecure(proxy: ValetProxy) async throws {
// TODO
}

View File

@@ -50,4 +50,10 @@ class ValetProxy: ValetListable {
func getListableUrl() -> URL? {
return URL(string: "\(self.secured ? "https://" : "http://")\(self.domain).\(self.tld)")
}
// MARK: - Interactions
func toggleSecure() async throws {
try await ValetInteractor.toggleSecure(proxy: self)
}
}

View File

@@ -8,7 +8,7 @@
import Foundation
class ValetSite: ValetListable, ValetInteractable {
class ValetSite: ValetListable {
/// Name of the site. Does not include the TLD.
var name: String
@@ -263,14 +263,10 @@ class ValetSite: ValetListable, ValetInteractable {
return URL(string: "\(self.secured ? "https://" : "http://")\(self.name).\(Valet.shared.config.tld)")
}
// MARK: ValetInteractable
// MARK: - Interactions
func secure() async throws {
try await ValetInteractor.secure(site: self)
}
func unsecure() async throws {
try await ValetInteractor.unsecure(site: self)
func toggleSecure() async throws {
try await ValetInteractor.toggleSecure(site: self)
}
func isolate(version: PhpVersionNumber) async throws {