-
Notifications
You must be signed in to change notification settings - Fork 63
Expand file tree
/
Copy pathbootstrap.php
More file actions
62 lines (52 loc) · 1.99 KB
/
bootstrap.php
File metadata and controls
62 lines (52 loc) · 1.99 KB
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
57
58
59
60
61
62
<?php
declare(strict_types=1);
namespace Mollie\WooCommerce;
use Inpsyde\Modularity\Package;
use Inpsyde\Modularity\Properties\PluginProperties;
use Psr\Container\ContainerInterface;
use Throwable;
/**
* Bootstrap function to initialize the plugin.
*
* @param string $root_dir The main plugin file path
* @param array $additional_modules Additional modules to load
* @return callable A function that returns the container
*/
return function (
string $root_dir,
array $additional_modules = []
): ContainerInterface {
try {
if(!function_exists('mollieWooCommerceIsCheckoutContext')){
require_once __DIR__ . '/inc/functions.php';
}
if (!function_exists('Mollie\WooCommerce\mollie_wc_plugin_autoload') || !mollie_wc_plugin_autoload()) {
throw new \RuntimeException('Autoloader could not be initialized.');
}
$checker = new Activation\ConstraintsChecker();
$meetRequirements = $checker->handleActivation();
if (!$meetRequirements) {
$nextScheduledTime = wp_next_scheduled('pending_payment_confirmation_check');
if ($nextScheduledTime) {
wp_unschedule_event($nextScheduledTime, 'pending_payment_confirmation_check');
}
throw new \RuntimeException('Plugin requirements not met.');
}
// Initialize plugin.
$properties = PluginProperties::new(M4W_FILE);
$package = Package::new($properties);
$modules = (require $root_dir . '/inc/modules.php')();
$modules = array_merge($modules, $additional_modules);
$modules = apply_filters('mollie_wc_plugin_modules', $modules);
foreach ($modules as $module) {
$package->addModule($module);
}
$package->boot();
return $package->container();
} catch (Throwable $throwable) {
if (function_exists('Mollie\WooCommerce\handleException')) {
handleException($throwable);
}
throw $throwable;
}
};