modified: README.md
This commit is contained in:
50
support-provisioning-portal/includes/class-spp-plugin.php
Normal file
50
support-provisioning-portal/includes/class-spp-plugin.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
if (!defined('ABSPATH')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
final class SPP_Plugin
|
||||
{
|
||||
private static ?SPP_Plugin $instance = null;
|
||||
|
||||
public static function instance(): SPP_Plugin
|
||||
{
|
||||
if (self::$instance === null) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
public function boot(): void
|
||||
{
|
||||
SPP_Activator::maybe_upgrade();
|
||||
|
||||
$repository = new SPP_Repository();
|
||||
$proxmox = $this->make_proxmox_client();
|
||||
$expiration_service = new SPP_Expiration_Service($repository, $proxmox);
|
||||
|
||||
add_action('spp_expire_deployments', [$expiration_service, 'expire_due_deployments']);
|
||||
|
||||
(new SPP_REST_Controller($repository, $proxmox, $expiration_service))->register_hooks();
|
||||
(new SPP_Admin_Page())->register_hooks();
|
||||
(new SPP_Shortcode())->register_hooks();
|
||||
}
|
||||
|
||||
private function make_proxmox_client(): SPP_Proxmox_Client
|
||||
{
|
||||
$mode = get_option('spp_proxmox_mode', 'mock');
|
||||
|
||||
if ($mode === 'http') {
|
||||
return new SPP_Http_Proxmox_Client([
|
||||
'base_url' => (string) get_option('spp_proxmox_base_url', ''),
|
||||
'token_id' => (string) get_option('spp_proxmox_token_id', ''),
|
||||
'token_secret' => (string) get_option('spp_proxmox_token_secret', ''),
|
||||
'node' => (string) get_option('spp_proxmox_node', ''),
|
||||
]);
|
||||
}
|
||||
|
||||
return new SPP_Mock_Proxmox_Client();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user