2021-08-27 20:40:09 +03:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Bootstraps the modular app.
|
|
|
|
*
|
|
|
|
* @package WooCommerce\PayPalCommerce
|
|
|
|
*/
|
|
|
|
|
2025-01-15 18:13:16 +04:00
|
|
|
namespace WooCommerce\PayPalCommerce;
|
|
|
|
|
2023-11-23 17:43:56 +00:00
|
|
|
use WooCommerce\PayPalCommerce\Vendor\Inpsyde\Modularity\Package;
|
|
|
|
use WooCommerce\PayPalCommerce\Vendor\Inpsyde\Modularity\Properties\PluginProperties;
|
2022-11-09 10:11:31 +02:00
|
|
|
use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface;
|
2021-08-27 20:40:09 +03:00
|
|
|
|
|
|
|
return function (
|
|
|
|
string $root_dir,
|
2023-03-01 16:20:08 +02:00
|
|
|
array $additional_containers = array(),
|
|
|
|
array $additional_modules = array()
|
2021-08-27 20:40:09 +03:00
|
|
|
): ContainerInterface {
|
2023-03-14 16:38:28 +02:00
|
|
|
/**
|
|
|
|
* Skip path check.
|
|
|
|
*
|
|
|
|
* @psalm-suppress UnresolvableInclude
|
|
|
|
*/
|
2021-08-27 20:40:09 +03:00
|
|
|
$modules = ( require "$root_dir/modules.php" )( $root_dir );
|
|
|
|
|
2023-03-01 16:20:08 +02:00
|
|
|
$modules = array_merge( $modules, $additional_modules );
|
|
|
|
|
2022-06-15 16:20:43 +03:00
|
|
|
/**
|
|
|
|
* Use this filter to add custom module or remove some of existing ones.
|
|
|
|
* Modules able to access container, add services and modify existing ones.
|
|
|
|
*/
|
2021-08-27 20:40:09 +03:00
|
|
|
$modules = apply_filters( 'woocommerce_paypal_payments_modules', $modules );
|
|
|
|
|
2023-11-23 17:43:56 +00:00
|
|
|
// Initialize plugin.
|
2025-07-04 20:18:23 +04:00
|
|
|
$properties = PluginProperties::new( "$root_dir/woocommerce-paypal-payments.php" );
|
2023-11-24 18:07:56 +00:00
|
|
|
$bootstrap = Package::new( $properties );
|
2021-08-27 20:40:09 +03:00
|
|
|
|
2023-12-19 17:26:09 +00:00
|
|
|
foreach ( $modules as $module ) {
|
|
|
|
$bootstrap->addModule( $module );
|
2023-12-15 14:16:53 +00:00
|
|
|
}
|
|
|
|
|
2023-11-23 17:43:56 +00:00
|
|
|
$bootstrap->boot();
|
|
|
|
|
|
|
|
return $bootstrap->container();
|
2021-08-27 20:40:09 +03:00
|
|
|
};
|