-
Notifications
You must be signed in to change notification settings - Fork 1
/
hooks.php
56 lines (45 loc) · 1.68 KB
/
hooks.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
use WHMCS\Module\Server\Katapult\Adaptation\AdminArea;
use WHMCS\Module\Server\Katapult\Adaptation\ClientArea;
use WHMCS\Module\Server\Katapult\Adaptation\System as SystemAdaptation;
use WHMCS\Module\Server\Katapult\Katapult\ParentOrganization;
use WHMCS\Module\Server\Katapult\Katapult\ValidateConfiguration;
if (!defined('WHMCS')) {
die('This file cannot be accessed directly');
}
require(__DIR__ . '/vendor/autoload.php');
// System
\add_hook('DailyCronJob', 0, [SystemAdaptation::class, 'syncConfigOptions']);
\add_hook('AfterCronJob', 0, [SystemAdaptation::class, 'syncVmBuilds']);
// Client checkout
\add_hook('ShoppingCartValidateProductUpdate', 0, function () {
$validator = new ValidateConfiguration(
\Katapult\APIClient(),
\Katapult\keyValueStore(),
);
return $validator->validateCartProducts($_SESSION['cart']['products']);
});
// Admin area
\add_hook('AdminProductConfigFields', 0, function ($vars) {
$configurationPane = new AdminArea\ConfigurationPane(
new ParentOrganization(
\Katapult\APIClient(),
\Katapult\keyValueStore(),
),
\Katapult\APIKey()
);
return $configurationPane($vars);
});
\add_hook('AdminProductConfigFieldsSave', 0, function ($vars) {
$updateConfiguration = new AdminArea\UpdateConfiguration(
new ParentOrganization(
\Katapult\APIClient(),
\Katapult\keyValueStore(),
),
\Katapult\APIKey()
);
$updateConfiguration($vars);
});
// JS and CSS assets
\add_hook('AdminAreaHeadOutput', 0, [AdminArea\Assets::class, 'addAssetsToHead']);
\add_hook('ClientAreaHeadOutput', 0, [ClientArea\Assets::class, 'addAssetsToHead']);